用vb.net 将数据库表名添加到ListBox1 5
ACCESS数据库已连接变量oleDbConnection1strsql="SELECTNAMEFROMMSysObjectsWHEREFlags=0ANDType=1"...
ACCESS数据库已连接变量oleDbConnection1
strsql = "SELECT NAME FROM MSysObjects WHERE Flags=0 AND Type=1"
ListBox 控件ListBox1
哪位大侠帮助写一下将strsql获取的表名添加与ListBox1,谢谢。 展开
strsql = "SELECT NAME FROM MSysObjects WHERE Flags=0 AND Type=1"
ListBox 控件ListBox1
哪位大侠帮助写一下将strsql获取的表名添加与ListBox1,谢谢。 展开
2个回答
展开全部
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\database\database1.mdb"
Dim con As New OleDb.OleDbConnection(cstring)
Dim sql As String = "select 姓名 from 学生信息表"
con.Open()
Dim cmd As New OleDb.OleDbCommand(sql, con)
Dim myreader As OleDbDataReader = cmd.ExecuteReader
Do While myreader.Read
ListBox1.Items.Add(myreader(0))
Loop
End Sub
Dim cstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\database\database1.mdb"
Dim con As New OleDb.OleDbConnection(cstring)
Dim sql As String = "select 姓名 from 学生信息表"
con.Open()
Dim cmd As New OleDb.OleDbCommand(sql, con)
Dim myreader As OleDbDataReader = cmd.ExecuteReader
Do While myreader.Read
ListBox1.Items.Add(myreader(0))
Loop
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询