其实是比较简单的,用心做就是了!
private void listBox3_SelectedIndexChanged(object sender, System.EventArgs e)
{
string Ss;
if (listBox3.SelectedIndex>=0)
{
Ss=listBox3.SelectedItem.ToString();
textBox20.Text=Ss;
//打开变电站信息列表
string myStr="Persist Security Info=False;Integrated Security=SSPI;database=Dlglxt;server=(local)";
SqlConnection myConn=new SqlConnection();
myConn.ConnectionString=myStr;
myConn.Open();
string myC_str="select * from SYS_bdzxx";
SqlCommand myCom=new SqlCommand();
myCom.CommandText=myC_str;
myCom.CommandType=CommandType.Text;
myCom.Connection=myConn;
SqlDataAdapter myDa=new SqlDataAdapter();
SqlCommandBuilder Builder=new SqlCommandBuilder(myDa);
myDa.SelectCommand=myCom;
DataSet myDs=new DataSet();
myDa.Fill(myDs,"SYS_bdzxx");
//判断名称是否重复
int Ii,Jj;
Jj=myDs.Tables["SYS_bdzxx"].Rows.Count;
for (Ii=0; Ii<Jj;Ii++)
{
Ss=(string)myDs.Tables["SYS_bdzxx"].Rows[Ii]["BDZ_name"];
Ss=Ss.Trim();
if (textBox20.Text.Trim()==Ss)
{ //变电站数据添充
textBox21.Text=myDs.Tables["SYS_bdzxx"].Rows[Ii]["BDZ_number"].ToString().Trim();
textBox22.Text=myDs.Tables["SYS_bdzxx"].Rows[Ii]["BDZ_telephone"].ToString().Trim();
textBox23.Text=myDs.Tables["SYS_bdzxx"].Rows[Ii]["BDZ_ip"].ToString().Trim();
textBox24.Text=myDs.Tables["SYS_bdzxx"].Rows[Ii]["BDZ_com"].ToString().Trim();
textBox25.Text=myDs.Tables["SYS_bdzxx"].Rows[Ii]["BDZ_dydj"].ToString().Trim();
}
myConn.Close();
}
}
}
[此贴子已经被作者于2006-10-24 11:08:43编辑过]