数据库连接不上,调试时指出“If rst.RecordCount > 0 Then”。问题出在哪里?怎么修改?
PrivateSubForm_Load()DimrstAsADODB.RecordsetDimstrItemAsString'初始化ComboBoxSQL="select...
Private Sub Form_Load()
Dim rst As ADODB.Recordset
Dim strItem As String
'初始化ComboBox
SQL = " select 用户ID,用户名称 from 用户信息表 order by 用户ID"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then
Do While Not rst.EOF
strItem = rst.Fields(0) & " " & rst.Fields(1)
CboName.AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboName.ListIndex = 0
Else
MsgBox ("请先创建用户信息!")
CmdOK.Enabled = False
Exit Sub
End If
End Sub 展开
Dim rst As ADODB.Recordset
Dim strItem As String
'初始化ComboBox
SQL = " select 用户ID,用户名称 from 用户信息表 order by 用户ID"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then
Do While Not rst.EOF
strItem = rst.Fields(0) & " " & rst.Fields(1)
CboName.AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboName.ListIndex = 0
Else
MsgBox ("请先创建用户信息!")
CmdOK.Enabled = False
Exit Sub
End If
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询