VB怎么把数据库读入到MSHFlexGrid

怎么写??
2024-11-18 20:35:47
推荐回答(1个)
回答(1):

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cn_1 As String, sql_1 As String
cn_1 = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb"
Set cn = New ADODB.Connection
cn.Open cn_1
sql_1 = "select * from 表1"
Set rs = New ADODB.Recordset
rs.Open sql_1, cn, adOpenStatic, adLockBatchOptimistic
Set MSHFlexGrid1.DataSource = rs