C# listbox控件 显示数据表中的数据

我正在编ATM程序 想做个账号查询 : 点击button1(重复点击不会添加行数的显示)触发事件,在listbox上显示数据表(SQL)中的帐户信息。本人C#菜鸟,请高手帮忙...
最新回答
妖孽只在夜里哭

2024-10-02 02:20:15

Data
Source=;\.Open();
sqlcon
=
new
SqlConnection(",
sqlcon)SqlConnection
sqlcon;);
SqlDataAdapter
sqlada;
sqlcon.DisplayMember
=
"
sqlada
=
new
SqlDataAdapter(str;
string
str
=
"
很简单的一个绑定
;
listBox1..Fill(a).;press;goodsname1".希望能帮到你;;Initial
Catalog=HQZPOSDB;.DefaultView;
DataSet
a
=
new
DataSet();
sqlada.DataSource
=
a;User
ID=sa.Tables[0];Password=zenii"goodsname1".ValueMember
=
"select
goodsname1
from
goods";
listBox1;
listBox1.\
时光让我们忘记模样

2024-10-02 00:44:28

SqlConnection sqlcon;
SqlDataAdapter sqlada;
sqlcon = new SqlConnection("Data Source=.\\press;Initial Catalog=HQZPOSDB;User ID=sa;Password=zenii");
sqlcon.Open();
string str = "select goodsname1 from goods";
sqlada = new SqlDataAdapter(str, sqlcon);
DataSet a = new DataSet();
sqlada.Fill(a);
listBox1.DisplayMember = "goodsname1";
listBox1.ValueMember = "goodsname1";
listBox1.DataSource = a.Tables[0].DefaultView;

很简单的一个绑定 ..希望能帮到你..
凤舞九天

2024-10-02 01:31:42

cloudyy17

说的就可以

你把他说的写进事件里 他点100次 也是生成1次
瑾色如弦

2024-10-02 02:06:53

SqlConnection sqlcon;
SqlDataAdapter sqlada;
sqlcon = new SqlConnection("Data Source=.\\press;Initial Catalog=HQZPOSDB;User ID=sa;Password=zenii");
sqlcon.Open();
string str = "select goodsname1 from goods";
sqlada = new SqlDataAdapter(str, sqlcon);
DataSet a = new DataSet();
sqlada.Fill(a);
listBox1.DisplayMember = "goodsname1";
listBox1.ValueMember = "goodsname1";
listBox1.DataSource = a.Tables[0].DefaultView;
残●沐伊丶

2024-10-02 01:51:42

你说的详细点,什么方面遇到问题了,要是都有问题那就很难帮你了