软件测试开发技术SQL Server数据库对象信息的获取[4] SQL Server数据库
关键字:sql End Sub
Private Sub cob_sqltable_Click()
’点击“数据表信息” 列表框
......
Dim oTable As SQLDMO.Table
Set oTable = oCurrentDB.Tables(cob_sqltable.List(cob_sqltable.ListIndex))
If oCurrentTable Is Nothing Then
Set oCurrentTable = oTable
Else
If oCurrentTable.Name = oTable.Name Then
Exit Sub
End If
Set oCurrentTable = Nothing
Set oCurrentTable = oTable
End If
FillEmptyColsToIndex (True)
If cob_sqlrecord.ListCount > 0 Then
cob_sqlrecord.ListIndex = 0
End If
......
End Sub
Private Sub FillEmptyColsToIndex(bFill As Boolean)
’获得数据表中的所有字段的信息
If bFill = True Then
Dim oCol As SQLDMO.Column
Set oCol = New SQLDMO.Column
For Each oCol In oCurrentTable.Columns
cob_sqlrecord.AddItem oCol.Name & “ ” & oCol.DataType
’把字段名称和字段属性添加到字段信息列表框中
Next oCol
End If
End Sub