sadhana sawant

sadhana sawant

  • NA
  • 7
  • 1.1k

i am trying to fetch customer address from database on selec

Feb 6 2015 3:20 AM
here is my code:
private void cmbCustomer_SelectedIndexChanged(object sender, EventArgs e)
{
//id = Convert.ToInt64(cmbCustomer.SelectedValue);
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand("select * from RM_Customer where custID ='" +Convert.ToInt64(cmbCustomer.SelectedValue) + "'", cn);
cn.Close();
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
txtaddress.Text = dr["custAddress"].ToString();
}
dr.Close();
cn.Close();
}
 
i got error like this:
Unable to cast object of type 'System.Data.DataRowView' to type 'System.IConvertible'
 
 
 
 

Answers (4)