| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 572 人关注过本帖
标题:[求助]如何用combo控件从库中取值显示
只看楼主 加入收藏
lwwsygdtc
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2006-12-15
收藏
 问题点数:0 回复次数:1 
[求助]如何用combo控件从库中取值显示

Private Sub Form_Load()
Dim rs As Recordset
Dim conn As Connectionhaha
End Sub

Private Sub haha()
Set rs = New Recordset
Set conn = New Connection
rs.Open "select * from InOutinfo", conn, adOpenKeyset, adLockPessimistic
Do While Not rs.EOF
Combo1.AddItem rs!发货地
rs.MoveNext
Loop
rs.Close
Set rs = Nothing

End Sub
我想从库中取一列值,显示在combo控件中,应该如何下手,窗口中用不用连库,有经验的大哥帮我写个标准版的用combo取值的语名呗,有空的话帮我改改上面的代码也成,谢谢啦

搜索更多相关主题的帖子: combo控件 库中 Sub Set conn 
2006-12-21 17:08
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 

我写过N次了...

Dim dbConn As ADODB.Connection
Dim Rst As ADODB.Recordset

Dim conString As String
conString = "Provider=sqloledb;Data Source=127.0.0.1;Initial Catalog =Northwind;User Id =sa;Password=coffee;"
Set dbConn = CreateObject("ADODB.Connection")

dbConn.ConnectionString = conString
dbConn.Open

Set Rst = CreateObject("ADODB.Recordset")
With Rst
.CursorLocation = adUseClient
.Open "select Distinct ShipCity from orders order by ShipCity asc", dbConn, adOpenForwardOnly, adLockReadOnly, adCmdText
End With

Dim i As Long
For i = 0 To Rst.RecordCount - 1
Combo1.AddItem Rst.Fields("ShipCity").Value
Rst.MoveNext
Next

Rst.Close
dbConn.Close
Set Rst = Nothing
Set dbConn = Nothing


我的msn: myfend@
2006-12-21 17:10
快速回复:[求助]如何用combo控件从库中取值显示
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035123 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved