當前位置:編程學習大全網 - 編程軟體 - 怎麽把數據庫裏的東西 用VB顯示出來

怎麽把數據庫裏的東西 用VB顯示出來

Dim conn As New ADODB.connection

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

  • 上一篇:職高的技能高考多少分能上大學
  • 下一篇:21款淩渡230解鎖車內燈光開啟設置方法
  • copyright 2024編程學習大全網