当前位置:编程学习 > C#/ASP.NET >>

dataset

 SqlDataAdapter shad = new SqlDataAdapter(shsql,shcon);
            DataSet shds =new DataSet();
            shad.Fill(shds);      
            if (shds.Tables[0].Rows.Count > 0)
            {
                int shoppingCartID = Convert.ToInt32(shds.Tables[0].Rows[0]["ShoppingCartID"]);                int quantity = Convert.ToInt32(shds.Tables[0].Rows[0]["Quantity"]);
注册红颜色到底什么意思啊 --------------------编程问答-------------------- 就是获得shds中第一个datatable中的第一行的"ShoppingCartID","Quantity"两个字段的值 --------------------编程问答-------------------- int shoppingCartID = Convert.ToInt32(shds.Tables[0].Rows[0]["ShoppingCartID"]);
这句是获得datatable中第一行 ShoppingCartID 列的值,并转换在int类型

int quantity = Convert.ToInt32(shds.Tables[0].Rows[0]["Quantity"]); 
这句是获得datatable中第一行 Quantity列的值,并转换在int类型

另外最好把值放在object里,转换前先检查是否为null。
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,