SqlConnection con1 = new SqlConnection("server=.;database=dxdata;uid=sa;pwd=");
string sql1 = " select 字段1 from 表1 where 受理编号='" + this.textBox1.Text + "'union all select 字段2 from 表2 where 受理编号='" + this.textBox1.Text + "'";
DataSet ds1 = new DataSet();
SqlDataAdapter adapter1 = new SqlDataAdapter(sql1, con1);
try
{
adapter1.Fill(ds1, "表1");
for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
{
comboBox2.Items.Add(ds1.Tables[0].Rows[i]["字段1"].ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
} SqlConnection con = new SqlConnection("server=.;database=dxdata;uid=sa;pwd=");
string sql = "select * from [dbo].[表1] where 受理编号 = '" + this.textBox1.Text + "'";
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(sql, con);
try
{
adapter.Fill(ds, "表1");
if (ds.Tables[0].Rows.Count > 0)
{
textBox3.Text = ds.Tables[0].Rows[0]["字段3"].ToString();
textBox4.Text = ds.Tables[0].Rows[0]["字段4"].ToString();
button3.Enabled = true;
}
else
{
MessageBox.Show("受理编号输入有误或该受理号不存在,请核实!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox1.Text = null;
textBox1.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
文字加粗的那段代码好像始终没有执行,请教问题出在哪里
string sql1 = " select 字段1 from 表1 where 受理编号='" + this.textBox1.Text + "'union all select 字段2 from 表2 where 受理编号='" + this.textBox1.Text + "'";
DataSet ds1 = new DataSet();
SqlDataAdapter adapter1 = new SqlDataAdapter(sql1, con1);
try
{
adapter1.Fill(ds1, "表1");
for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
{
comboBox2.Items.Add(ds1.Tables[0].Rows[i]["字段1"].ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
} SqlConnection con = new SqlConnection("server=.;database=dxdata;uid=sa;pwd=");
string sql = "select * from [dbo].[表1] where 受理编号 = '" + this.textBox1.Text + "'";
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(sql, con);
try
{
adapter.Fill(ds, "表1");
if (ds.Tables[0].Rows.Count > 0)
{
textBox3.Text = ds.Tables[0].Rows[0]["字段3"].ToString();
textBox4.Text = ds.Tables[0].Rows[0]["字段4"].ToString();
button3.Enabled = true;
}
else
{
MessageBox.Show("受理编号输入有误或该受理号不存在,请核实!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox1.Text = null;
textBox1.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
文字加粗的那段代码好像始终没有执行,请教问题出在哪里
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货