我没用的2008 ,这是2005里我写的
Dim constr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\zr.mdb;Jet OLEDB:Database Password=1234 "
Dim olecon As OleDbConnection
olecon = New OleDbConnection(constr)
Dim comstr As String = "select * from cb where cname='ww'"
Dim comm As New OleDbCommand(comstr, olecon)
Dim rr As OleDbDataReader
rr = comm.ExecuteReader
If rr.Read() Then
messagebox.show("查询记录成功")
rr.Close()
comm.Dispose()
olecon.Close()
olecon.Dispose()
End If
MyConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=数据库;"
Dim path As String = "D:\vb\TEXT\Sj\Sj\data\Access_2007.accdb"
Dim conn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path & ";Jet OLEDB:Database Password=MyDbPassword;"