C#net listview控件获取表格数据,第二次不行,求救。
private void LstShow_SelectedIndexChanged(object sender, EventArgs e){
data.Con.Open();
string strSql;
string ss;
ss = LstShow.SelectedItems[0].SubItems[1].Text.ToString();
strSql = " Select CustName,CustTel,CustCz,CustYb,CustLxr,CustAddress from Customer where custName='" + ss + "'";
OleDbCommand Com = new OleDbCommand(strSql, data.Con);
OleDbDataReader Reader;
Reader = Com.ExecuteReader();
if (Reader.Read())
{
txtName.Text = Reader["CustName"].ToString();
txtTel.Text = Reader["CustTel"].ToString();
txtCz.Text = Reader["CustCz"].ToString();
txtYb.Text = Reader["CustYb"].ToString();
txtLxr.Text = Reader["CustLxr"].ToString();
txtAddress.Text = Reader["CustAddress"].ToString();
data.Con.Close();
}
}
第一次点显示没问题,第二次点就出问题
ss = LstShow.SelectedItems[0].SubItems[1].Text.ToString();
InvalidArgument=“0”的值对于“index”无效。
参数名: index
补充:.NET技术 , C#