ComboBox控件输入文本弹出下拉列表根据输入的文本在数据库查找~~ onchange事件中,根据内容区select数据集,然后遍历数据集,添加到items 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 选择a,返回b private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string Sql = "select b from table where a =' " + comboBox1.SelectedItem + "'' "; string connectionString = "Data Source=192.168.1.3;Initial Catalog=data;User ID=sa;password=sa;Integrated Security=False"; string queryString = Sql; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(queryString, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { textBox1.Text = reader[0].ToString(); } } finally { command.Dispose(); connection.Close(); } } } select * from phonetable where name like '%"+txtBoxID.text+"%' http://bbs.csdn.net/topics/390324804像百度那样的 关键字 'and' 附近有语法错误。 用正则表达式提取字符的问题 新手求救,一道操作符重载的题,急呀! 突然想到一个问题,请教大家. 基于xml动态界面设计 如何制作类似QQ风格的窗体界面 请问windows datagrid中的滚动条是自动出现的还是可以自己设置的 foreach循环的内部好像不能给迭代的对象赋值啊,为什么? 如何把对象串行化存入数据库 怎么理解事件和委托,大家给点解释,好么?好帮助我理解!! 新人发帖求助关于listbox双击事件的一系列问题 有没有办法在image控件上加上textbox,也就是实现在图片上写字?
选择a,返回b
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string Sql = "select b from table where a =' " + comboBox1.SelectedItem + "'' ";
string connectionString = "Data Source=192.168.1.3;Initial Catalog=data;User ID=sa;password=sa;Integrated Security=False";
string queryString = Sql;
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
textBox1.Text = reader[0].ToString();
}
}
finally
{
command.Dispose();
connection.Close(); }
}
}
像百度那样的