Private Sub List1_Click() Dim strSql as string dim myRs as New ADODB.Recordset dim Connstr as string Connstr="......" '连接数据库的字符串 strSql ="Select * From Table WHere Name='" & List1.Text & "'" myrs.open strsql,Connstr list2.clear do while not myrs.eof list2.additem myrs.fields(0).values '或者其它列也可以 myrs.movenext loop myrs.close End Sub
Private Sub List1_Click() Dim strSql as string dim myRs as New ADODB.Recordset,dim conn as new adodb.connection dim Connstr as string Connstr="......" '连接数据库的字符串 conn.open Connstr strSql ="Select * From Table1 WHere Name='" & List1.Text & "'" myRs.open strsql,Conn list2.clear do while not myrs.eof list2.additem myrs.fields(0).values '或者其它列也可以 myrs.movenext loop myrs.close conn.close End Sub
来了 来了,怎么两个回答都一样? 呵呵 哦看错 clear_zero(清晰)兄: myrs.close conn.close这样和只写 myrs.close 区别在哪里?另外: 随用随创建 New ADODB.Recordset 和 new adodb.connection 会不会影响速度?
Dim strSql as string
dim myRs as New ADODB.Recordset
dim Connstr as string
Connstr="......" '连接数据库的字符串
strSql ="Select * From Table WHere Name='" & List1.Text & "'"
myrs.open strsql,Connstr
list2.clear
do while not myrs.eof
list2.additem myrs.fields(0).values '或者其它列也可以
myrs.movenext
loop
myrs.close
End Sub
Dim strSql as string
dim myRs as New ADODB.Recordset,dim conn as new adodb.connection
dim Connstr as string
Connstr="......" '连接数据库的字符串
conn.open Connstr
strSql ="Select * From Table1 WHere Name='" & List1.Text & "'"
myRs.open strsql,Conn
list2.clear
do while not myrs.eof
list2.additem myrs.fields(0).values '或者其它列也可以
myrs.movenext
loop
myrs.close
conn.close
End Sub
哦看错
clear_zero(清晰)兄:
myrs.close
conn.close这样和只写
myrs.close
区别在哪里?另外:
随用随创建
New ADODB.Recordset 和 new adodb.connection
会不会影响速度?