主题:连接好数据库后,怎样返回所有的表到组合框?
yl52020
[专家分:30] 发布于 2005-01-13 15:05:00
连接好数据库后,怎样返回所有的表到组合框?(事先不知道库里有多少表)
回复列表 (共3个回复)
沙发
yl52020 [专家分:30] 发布于 2005-01-13 15:07:00
表指的是表名.
板凳
qingdaofeng [专家分:3160] 发布于 2005-01-14 22:03:00
do while not rst.eof
com.additem rst("your_fields")
rst.movenext
loop
3 楼
yh5530 [专家分:0] 发布于 2005-01-31 01:29:00
给你一段如何调取SQL Server数据库中数据表的源码:
Dim mcnn As New OleDb.OleDbConnection(BuildCnnStr(MSserver, MDdatabase))
Dim mycommand As New OleDb.OleDbCommand("sp_tables", mcnn)
Dim myread As OleDb.OleDbDataReader
Try
mycommand.CommandType = CommandType.StoredProcedure
mcnn.Open()
myread = mycommand.ExecuteReader
Do While myread.Read
If myread.GetString(3) = "TABLE" Then
Me.Cmbtable.Items.Add(myread.GetString(2))
End If
Loop
mcnn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "错误信息", MessageBoxButtons.OK)
End Try
我来回复