主题:怎么在VB.net中访问数据库啊?
zcxlhx
[专家分:720] 发布于 2005-10-14 13:54:00
在VB6.0中访问数据是很轻松了,但在vb.net中就不行了,怎么在vb.net中访问一个*.mdb的数据库文件,进行查询更新删除等操作?
最好是给一个例子。
回复列表 (共1个回复)
沙发
宝宝啊呜 [专家分:990] 发布于 2005-10-14 16:06:00
Imports System.Data
Imports System.Data.OleDb
Dim connStr, selectCmd As String, i As Integer
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DB.mdb"
selectCmd = "Select * From SCORE"
Dim conn As OleDbConnection, myAdapter As OleDbDataAdapter
conn = New OleDbConnection(connStr)
conn.Open()
Dim myDataSet As DataSet = New DataSet()
myAdapter = New OleDbDataAdapter(selectCmd, conn)
myAdapter.Fill(myDataSet, "成绩单")
DataGrid1.DataGrid1.DataSource = myDataSet.Tables("成绩单")
conn.Close()
我来回复