用VB查询一个表中同时包含两个字段的记录,然后统计记录的数量.如何获取数量的值.strcon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Menjin;Data Source=WIN-3F96VLME8V7"cnn.Op
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 18:32:35
用VB查询一个表中同时包含两个字段的记录,然后统计记录的数量.如何获取数量的值.strcon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Menjin;Data Source=WIN-3F96VLME8V7"cnn.Op
用VB查询一个表中同时包含两个字段的记录,然后统计记录的数量.如何获取数量的值.
strcon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Menjin;Data Source=WIN-3F96VLME8V7"
cnn.Open strcon
rst.Open "select * from Product",cnn,adOpenDynamic,adLockOptimistic
Set rsti = cnn.Execute("select * from Product where Class_A=' " & Trim(Cb_1.Text) & " 'and Class_B=' " & Trim(Cb_2.Text) & " ' ")
If Not rsti.BOF Then rsti.MoveFirst
Do While Not rsti.EOF
i = i + 1
rsti.MoveNext
Loop
' i = Int(rsti.RecordCount)
lab_bianhao.Caption = Trim(Cb_1.Text) & Trim(Cb_2.Text) & (i + 1)
我想获取i的值,这样能看懂吗?
用VB查询一个表中同时包含两个字段的记录,然后统计记录的数量.如何获取数量的值.strcon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Menjin;Data Source=WIN-3F96VLME8V7"cnn.Op
你是不是想获得 Product table里,同时满足classa='a' and classb='b' 的记录有多少条?
你可以用
Set rsti = cnn.Execute("select count(*) from Product where Class_A=' " & Trim(Cb_1.Text) & " 'and Class_B=' " & Trim(Cb_2.Text) & " ' ")
i=rsti(0)
就是你要的结果了