日期:2014-05-17  浏览次数:20826 次

ASP.NET SqlDataReader从数据库中得到了多行数据,该怎么分别得到这些数据呀?
我用的NextResult()怎么总是只能得到一行数据呀?

SqlCommand Selectcmd = new SqlCommand("select PackageDetail_Info.Count,Project_Info.Price from PackageDetail_Info,Project_Info where PackageDetail_Info.Project_ID=Project_Info.Project_ID and Package_ID='" + Package_ID + "'", conn);
                    System.Data.SqlClient.SqlDataReader dr = Selectcmd.ExecuteReader();
                    while (dr.Read())
                    {
                        Response.Write("<script language=javascript>alert('int count = dr.GetInt32(0);')</script>");
                        //for (int k = 0; k <= dr.FieldCount;k++ )
                        {
                            //Label2.Text = dr.GetInt32(0).ToString().Trim();
                            //Label3.Text = dr.FieldCount.ToString().Trim();
                            int count = dr.GetInt32(0);
                            Response.Write("<script language=javascript>alert('1')</script>");
                            double Price = dr.GetDouble(1);
                            total = total + count * Price;
                        }
                        if (dr.NextResult())
                        {
                            //dr.NextResult();
                            dr.Close();
                        }
&n