求助 !!!如何得到统计数量
Dim myconnection As SqlConnection
myconnection = New SqlConnection("Data Source=(local);Uid=sa;pwd=221;DataBase=在线图书销售")
Dim cs As String
cs = "select sum(总计) from 购物车"
Dim selectcommand As SqlCommand = New SqlCommand(cs, myconnection)
Dim reader As SqlDataReader
Dim temp As String
myconnection.Open()
reader = selectcommand.ExecuteReader()
temp = reader.Read()
Label3.Text = reader.Item("sum(总计)")?????
myconnection.Close()
中倒数第2行 语句怎么导出到LABEL里面?
问题点数:20、回复次数:2Top
1 楼lyfer(叼着白沙写程序)回复于 2006-06-04 19:13:00 得分 0
cs = "select sum(总计) from 购物车"
改为
cs = "select sum(总计) as [sum] from 购物车"
Label3.Text = reader.Item("sum")
Top
2 楼fangxinggood(JustACoder)回复于 2006-06-05 10:32:15 得分 0
cs = "select sum(总计) as total from 购物车"
Dim selectcommand As SqlCommand = New SqlCommand(cs, myconnection)
Dim reader As SqlDataReader
Dim temp As String
myconnection.Open()
reader = selectcommand.ExecuteReader()
if(reader.Read())
temp = reader.Item("total")
Label3.Text = temp
reader.Close() 'Reader用完要关闭。
myconnection.Close()Top




