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