没人回答,昨晚自己整明白了,和大家分享一下!
的资料真是太少,大家应该多多分享!
Dim dbaname As String = "\data\py.mdb" '指定数据库文件路径及名称
Dim connStr As String = "provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & CurDir() & dbaname
Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection(connStr)
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand
Dim sql As String = "select * from pylj"
conn.Open()
cmd.Connection = conn
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sql, conn)
Dim ds As New Data.DataSet()
da.Fill(ds, "pylj")
DataGridView1.DataSource = ds.Tables(0)