给你一段代码慢慢研究吧- Dim mycon As New ADODB.Connection
- Dim myrs As New Recordset
- Private Sub Form_Load()
- mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb;Persist Security Info=False"
- mycon.Open
- myrs.ActiveConnection = mycon
- myrs.CursorType = adOpenDynamic
- myrs.CursorLocation = adUseClient
- myrs.Open "select * from Categories"
- Set DataGrid1.DataSource = myrs
- DataGrid1.Refresh
- End Sub
红色的部分自己改成你连接的数据库名和表名 |