comboBox 控件已经和数据库绑定了 怎么把查询的结果添加comboBox的选项中去啊 就是运行时 我按一下COMBOBO
comboBox控件已经和数据库绑定了怎么把查询的结果添加comboBox的选项中去啊就是运行时我按一下COMBOBOX的下拉按钮它就会有结果显示出来啊?...
comboBox 控件已经和数据库绑定了 怎么把查询的结果添加comboBox的选项中去啊 就是运行时 我按一下COMBOBOX的下拉按钮 它就会有结果显示出来啊?
展开
3个回答
展开全部
数据库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
展开全部
不知道你用的什么语言及工具开发的,给你delphi的代码
ComboBox1.Items.Clear;
DataSet1.First;
while not DataSet1.Eof do
begin
ComboBox1.Items.Add(DataSet1.FIeldByName('fieldname').AsString);
DataSet1.Next;
end;
ComboBox1.Items.Clear;
DataSet1.First;
while not DataSet1.Eof do
begin
ComboBox1.Items.Add(DataSet1.FIeldByName('fieldname').AsString);
DataSet1.Next;
end;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
combobox.items.add()
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询