请高手帮忙写一段VB连接Access数据库的代码,需要实现模糊查询的功能!表的名字query
1个回答
展开全部
public sub connection()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
dim sqlStr as String
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb;Persist Security Info=False"
cn.Open
sqlStr = ""select * From query where name like" & "%" &你的条件&"%"
rs.Open sqlStr, cn, sqlStr,adOpenStatic, adLockPessimistic
debug.print rs.Fields(0)
end sub
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
dim sqlStr as String
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb;Persist Security Info=False"
cn.Open
sqlStr = ""select * From query where name like" & "%" &你的条件&"%"
rs.Open sqlStr, cn, sqlStr,adOpenStatic, adLockPessimistic
debug.print rs.Fields(0)
end sub
更多追问追答
追答
加不上
追问
验证 林子悠
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询