(1)安裝VB6.0。

(2)可能需要下載並安全補丁。

 

(3)註冊控制項。regsvr32 msdatgrd.ocx

 

(4)代碼。

 

Dim wsPath As String, conString As String
Dim db As New ADODB.Connection
Dim troubleRS As New ADODB.Recordset
wsPath = ThisDrawing.Application.Preferences.Files.WorkspacePath
conString = "File Name=" & wsPath & "\trouble.udl"
db.Open conString
If Err <> 0 Then
MsgBox "Could not open circles.udl."
Exit Sub
End If
troubleRS.CursorLocation = adUseClient
troubleRS.Open "TROUBLE", db, adOpenDynamic, adLockOptimistic
If Err <> 0 Then
MsgBox "Could not open circles recordset"
Exit Sub
End If

 

Set DataGrid1.DataSource = troubleRS
'troubleRS.Close
'db.Close 資料庫不能close,否則資料會一閃而過。
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()