Dim rs As New ADODB.Recordset
Dim sql As String
Dim connstr As String
Dim dbPath As String
Dim tableName As String
dbPath="d:\A.mdb" '數據庫路徑
tableName="B" '表名
connstr = "provider=microsoft.jet.oledb.4.0;data source=" & dbPath
sql = "select * from " & tableName & " where id ='" & Text1.Text & "'" 'Text1中是妳要查詢題目的編號
conn.open (connstr)
rs.open sql, conn, 3, 3
If rs.recordcount > 0 Then
rs.MoveFirst
Label1.Caption = rs("Title") '題目
Option1(0).Caption=rs("A") '選項A
Option1(1).Caption=rs("B") '選項B
Option1(2).Caption=rs("C") '選項C
Option1(3).Caption=rs("D") '選項D
End If
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing