选择查询中的动态组合值 [英] Dnamic comboox value in a select Query
本文介绍了选择查询中的动态组合值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们,我需要根据组合框选择的事件在网格视图中绑定值.我得到nw的问题是值未从数据库中获取,这是因为op的组合框值请帮助我...该值应从数据库中检索...
注意:组合框"值包含数据库列名称"
这是我的代码
Hi friends i need to bind the value in grid view as per the Combobox selected Event..The Problem which i got nw is the value is not retrieving from an database am getting the op as combobox value pls help me... The value should retrieve from an database...
Note: The Combo box value contain the database column Names
Here is my code
string a = comboBox1.SelectedItem.ToString();
string a1 = comboBox2.SelectedItem.ToString();
groupBox3.Visible = true;
da = new SqlDataAdapter("select '" + a + "','" + a1 + "' from probablitystate1 ", cn.con);
dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
n你...
:-)
Thnak You...
:-)
推荐答案
嗨
请从查询中删除单引号,然后尝试.
Hi
Please remove the single quotes from the query and try.
string a = comboBox1.SelectedItem.ToString();
string a1 = comboBox2.SelectedItem.ToString();
groupBox3.Visible = true;
da = new SqlDataAdapter("select " + a + "," + a1 + " from probablitystate1", cn.con);
dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
删除查询中的单引号.
Remove single quotes in your query.
da = new SqlDataAdapter("select " + a + "," + a1 + " from probablitystate1 ", cn.con);
这篇关于选择查询中的动态组合值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文