如何使用下拉列表检索数据库中的记录? [英] how to retreive record in database using drop down list?

查看:58
本文介绍了如何使用下拉列表检索数据库中的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void frmsupplier_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dbAutorecDataSet.supplier' table. You can move, or remove it, as needed.
            this.supplierTableAdapter.Fill(this.dbAutorecDataSet.supplier);
              SqlDataAdapter da = new SqlDataAdapter("select * from supplier", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "supplier");
            DataView dv = new DataView(ds.Tables["supplier"]);
            da.Fill(dtspp);
            showCurrentRecord();
            SqlCommand cmd=new SqlCommand("select * from supplier where suppId='" + comboBox1.SelectedValue.ToString() + "'", con);
        }

推荐答案

在组合框选择的更改事件中,您应该调用数据库并将结果转储到数据表中并将其与某个地方绑定.

In combobox selected change event, you should call database and dump the results into datatable and bind it with somewhere.

protected void comboBox1_IndexChanged(object sender, EventArgs e)
      {
 SqlCommand cmd=new SqlCommand("select * from supplier where suppId='" + comboBox1.SelectedValue.ToString() + "'", con);
//then all the sql command, retreival comes here


这篇关于如何使用下拉列表检索数据库中的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆