在一个windows窗体里,有两个文本框textID,textName 想在textID中输入一个编号,例如001,回车在textName显示与其对应的姓名。 (SQL调用customer数据库中的表guest) 最好能给出具体的参考代码。我也知道大体思路....
谢谢啦...............
解决方案 »
- winform中datagidview问题
- C#连接Excel问题。很纠结 很纠结
- 请问如何单独指定SqlDataAdapter.selectcommand的connection?
- 水晶报表数据源更新
- c#连接oracle出现时:ORA-12154: TNS: 无法解析指定的连接标识符
- 报错为:用户代码未处理UnauthorizedAccessException,请问这是什么错误???
- DataTable中删除的行无法显示在ListBox中
- (请指点)asp.net application下 如何在web窗体中实现类似选项卡的效果!
- c#.net的窗体布局-当窗体设为Maximized是,任务栏就看不见了
- C#求一个数的绝对值的方法是什么?
- 分布式仿真中通信协议如何实现
- C# 怎么在sql数据库中插入一行数据
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)//enter
{
textBox2.Text = "Here is " + textBox1.Text;
}
}
select textname的字段名 from guest where textID的字段名 = textID的文本值
然后cmd对象,调用cmd的ExecuteScalar()方法。
给你写个sql语句看看合适不:
string sql_se="select name(姓名) from guest(表) where id='"+this.textID.Text+"'";
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
textBox1.Text = textBox1.Text.ToString();
string ssql = " select * from Guest_info where guestid='"+textBox1.Text+"'";
DataSet dtquery = new DataSet();
if (e.KeyCode == Keys.Enter)
{
if (textBox1.Text.Trim() != "")
{
try
{
textBox1.Text = string.Format("{0:000000}", Convert.ToInt16(textBox1.Text));
textBox2.Text = SqlHelper.ExecuteScalar(SqlHelper.connectionString, CommandType.Text, "select guestname from guest_Info where guestid='" + textBox1.Text.Trim() + "'").ToString();
textBox3.Text = SqlHelper.ExecuteScalar(SqlHelper.connectionString, CommandType.Text, "select unit from guest_Info where guestid='" + textBox1.Text.Trim() + "'").ToString();
textBox4.Text = SqlHelper.ExecuteScalar(SqlHelper.connectionString, CommandType.Text, "select address from guest_Info where guestid='" + textBox1.Text.Trim() + "'").ToString();
}
catch
{
MessageBox.Show("请正确输入客户编号!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}