关于vb条件查找数据库中的内容,急啊,求大虾帮忙啊
Dim db As New adodb.Connection
Dim rs As New adodb.Recordset
Private Function showgrid(ByVal s As String)
Set db = New adodb.Connection
db.CursorLocation = adUseClient
sqlconnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Highway;Data Source=PC松子-PC"
Set rs = New adodb.Recordset
If s = "" Then
rs.Open "select *from Employees", db, adOpenStatic, adLockOptimistic
Else
rs.Open "select * from Employees where" & Trim(Combo1.Text) & "='" & Trim(Text1.Text) & "'", db, adOpenStatic, adLockOptimistic
End If
Set DataGrid1.DataSource = rs
End Function
通过不同的条件选择不同的记录,然后显示在datagrid上,求赐教,这个为什么不行啊??为什么会错呢??提示是无法连接,并且没有预期的效果,因为是新手,没有多少分,望见谅
[解决办法]
db.CursorLocation = adUseClient
sqlconnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Highway;Data Source=PC松子-PC"
db.open sqlconnection,没有打开连接,
Set rs = New adodb.Recordset
[解决办法]
db.CursorLocation = adUseClient??这也错了吧