vb listbox显示数据库内容
DimDBAsNewDatabase‘数据库连接类模块DimResultCountAsIntegerDB.rsType=True'数据库打开方式DB.RunSelectS...
Dim DB As New Database‘数据库连接类模块
Dim ResultCount As Integer
DB.rsType = True '数据库打开方式
DB.RunSelectSQL ("SELECT 站号 From a GROUP BY 站号")ListSTN
现在想把 上面查询语句里的内容在listbox ListSTN中显示 应该怎么写 展开
Dim ResultCount As Integer
DB.rsType = True '数据库打开方式
DB.RunSelectSQL ("SELECT 站号 From a GROUP BY 站号")ListSTN
现在想把 上面查询语句里的内容在listbox ListSTN中显示 应该怎么写 展开
1个回答
展开全部
给你一段代码,看你能否看懂,看不懂再说
Sub Combox_AddItem(P_Form_Control As Object, P_Feild As String, P_Record_Name As String, Optional p_sql As String)
Dim W_Rb As New ADODB.Recordset
Dim W_Sql As String
W_Sql = "Select distinct " & P_Feild & " as Tmp_Feild From " & P_Record_Name & " Where isnull(" & P_Feild & ",'')<>''" & p_sql & " ORDER BY " & P_Feild
P_Form_Control.Clear
'常用人员名单
With W_Rb
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.ActiveConnection = G_Con
.Open W_Sql
End With
While W_Rb.EOF <> True
P_Form_Control.AddItem W_Rb!Tmp_Feild
W_Rb.MoveNext
Wend
W_Rb.Close
Set W_Rb = Nothing
End Sub
Sub Combox_AddItem(P_Form_Control As Object, P_Feild As String, P_Record_Name As String, Optional p_sql As String)
Dim W_Rb As New ADODB.Recordset
Dim W_Sql As String
W_Sql = "Select distinct " & P_Feild & " as Tmp_Feild From " & P_Record_Name & " Where isnull(" & P_Feild & ",'')<>''" & p_sql & " ORDER BY " & P_Feild
P_Form_Control.Clear
'常用人员名单
With W_Rb
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.ActiveConnection = G_Con
.Open W_Sql
End With
While W_Rb.EOF <> True
P_Form_Control.AddItem W_Rb!Tmp_Feild
W_Rb.MoveNext
Wend
W_Rb.Close
Set W_Rb = Nothing
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询