关于VB 连接数据库的问题
我想用VB做一个查询功能的程序,要连接access数据库。例:输入张三 能得到张三的所有属性。请问要如何用VB 连接access,那个代码如何写,还有查询代码。求帮忙。谢谢。本人是新手 不懂~~谢谢各位了。分一定给~
Public Const Cn_String1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
Public Work_cn As New ADODB.Connection
Public Work_rs As New ADODB.Recordset
'连接
Public Function ConnectWorkDataBase(ByVal FileName As String) As Boolean
Try
Work_cn.Open(Cn_String1 & FileName)
Return True
Catch ex As Exception
End Try
Return False
End Function
'查询
Dim Sql As String = "select * from tb1"
Work_rs.Open(Sql, Work_cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)