VB.NET中 combobox控件绑定ACCESS数据库字段问题
ACCESS数据库:考场表绑定字段:考场号用代码编写,不用向导combobox控件名:combobox1我试过,由于能力有限总是不行,哪个高手帮一下把完整代码写下来,用来...
ACCESS数据库:考场表 绑定字段:考场号
用代码编写,不用向导
combobox控件名:combobox1
我试过,由于能力有限总是不行 ,哪个高手帮一下把完整代码写下来,用来参考下啊! 展开
用代码编写,不用向导
combobox控件名:combobox1
我试过,由于能力有限总是不行 ,哪个高手帮一下把完整代码写下来,用来参考下啊! 展开
1个回答
展开全部
数据库db1.mdb
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New OleDbConnection _
("provider=microsoft.jet.oledb.4.0;data source=db1.mdb")
Dim mydataset As New DataSet()
Dim myadapter As New OleDbDataAdapter("select * from 考场表", conn)
conn.Close()
myadapter.Fill(mydataset, "考场表")
ComboBox1.DataSource = mydataset
ComboBox1.DisplayMember = "考场表.考场号 "
conn.Close()
End Sub
End Class
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New OleDbConnection _
("provider=microsoft.jet.oledb.4.0;data source=db1.mdb")
Dim mydataset As New DataSet()
Dim myadapter As New OleDbDataAdapter("select * from 考场表", conn)
conn.Close()
myadapter.Fill(mydataset, "考场表")
ComboBox1.DataSource = mydataset
ComboBox1.DisplayMember = "考场表.考场号 "
conn.Close()
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询