在開發基於SQL Server數據庫的應用程序時
本文所列出的代碼在Windows NT
利用SQL
在
在代碼中定義以下全局變量
Public oSQLServer As SQLDMO
Public oCurrentDB As SQLDMO
Public oCurrentTable As SQLDMO
Public SERVER_NAME As String
Public USERNAME As String
Public PASSWORD As String
以下為部分關鍵的程序代碼
Private Sub cmd_link_Click()
Set oSQLServer = CreateObject(
oSQLServer
FillEmptyDatabaseList (True)
If cob_sqldb
cob_sqldb
Cob_sqldb_Click
End If
End Sub
Private Sub FillEmptyDatabaseList(bFill As Boolean)
If bFill = True Then
Dim oDB As SQLDMO
Set oDB = New SQLDMO
For Each oDB In oSQLServer
If oDB
cob_sqldb
End If
Next oDB
End If
End Sub
Private Sub Cob_sqldb_Click()
Dim oDB As SQLDMO
Set oDB = oSQLServer
If oCurrentDB Is Nothing Then
Set oCurrentDB = oDB
Else
If oCurrentDB
Exit Sub
End If
Set oCurrentDB = Nothing
Set oCurrentDB = oDB
End If
FillEmptyTableList (True)
If cob_sqltable
cob_sqltable
cob_sqltable_Click
End If
End Sub
Private Sub FillEmptyTableList(bFill As Boolean)
If bFill = True Then
Dim oTable As SQLDMO
For Each oTable In oCurrentDB
If oTable
cob_sqltable
End If
Next oTable
End If
End Sub
Private Sub cob_sqltable_Click()
Dim oTable As SQLDMO
Set oTable = oCurrentDB
If oCurrentTable Is Nothing Then
Set oCurrentTable = oTable
Else
If oCurrentTable
Exit Sub
End If
Set oCurrentTable = Nothing
Set oCurrentTable = oTable
End If
FillEmptyColsToIndex (True)
If cob_sqlrecord
cob_sqlrecord
End If
End Sub
Private Sub FillEmptyColsToIndex(bFill As Boolean)
If bFill = True Then
Dim oCol As SQLDMO
Set oCol = New SQLDMO
For Each oCol In oCurrentTable
cob_sqlrecord
Next oCol
End If
End Sub
From:http://tw.wingwit.com/Article/program/SQLServer/201311/22095.html