VB6:如何在 DataGrid 中显示 SQLite

VB6:如何在 DataGrid 中显示 SQLite
Private Sub Form_Load()
Dim sqlstr As String
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection

Dim rs As New ADODB.Recordset
Set conn = New ADODB.Connection
conn.ConnectionString = "DRIVER=SQLite3 ODBC Driver;Database=" & App.Path & "/database.db;"
conn.Open

rs.Open "SELECT * FROM tblGiat", conn, adOpenKeyset

MsgBox "Total Number of records = " & rs.RecordCount

End Sub

我已成功将数据库连接到 VB6。现在我需要帮助,如何将该数据库显示到 DataGrid 中。

答案1

Private Sub Form_Load()
Dim sqlstr As String
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection

Dim rs As New ADODB.Recordset
Set conn = New ADODB.Connection
conn.ConnectionString = "DRIVER=SQLite3 ODBC Driver;Database=" & App.Path & "/database.db;"
conn.Open

rs.Open "SELECT * FROM tblGiat", conn, adOpenKeyset

MsgBox "Total Number of records = " & rs.RecordCount

Set DataGrid1.DataSource = rs

End Sub

相关内容