早教吧 育儿知识 作业答案 考试题库 百科 知识分享

关于count(*)的问题?我想统计数据库里面的人数,用count(*)来做,但出错,不知道什么原因,DimconnAsNewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath("access\data.mdb"))Dimstrsql1,strsql2,str

题目详情
关于count(*)的问题?
我想统计数据库里面的人数,用count(*)来做,但出错,不知道什么原因,
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("access\data.mdb"))
Dim strsql1,strsql2,strsql3 As String
strsql1 = "select count(*) as total from signup where room_num like '5%'"
Dim cmd1 As New OleDbCommand(strsql1,conn)
Dim dr1 As OleDbDataReader = cmd1.ExecuteReader()
If dr1.Item("total") < 36 Then
message5.Text = dr1.Item("total")
Else
message5.Text = "已满"
End If
运行时提示这里出错:If dr1.Item("total") < 36 Then
搜索更多相关主题的帖子:count(*)
▼优质解答
答案和解析
Dim dr1 As OleDbDataReader = cmd1.ExecuteReader()
If dr1.Read() Then
If dr1.Item("total") < 36 Then
message5.Text = dr1.Item("total")
Else
message5.Text = "已满"
End If
End If