pooriajojo
پنج شنبه 14 اسفند 1393, 12:53 عصر
سلام من تو اتصال به پایگاه داده مشگل دارم . این قسمت :
من اینا نوشتم
SqlConnection connection = new SqlConnection();
connection.ConnectionString = @"Data Source=(local);Initial Catalog=khadamat;Integrated Security=True";
SqlCommand command = new SqlCommand("select namep,neshanp,idmeli,daraje from personel1 where id='" + txid.Text + "'", connection);
connection.Open();
SqlDataReader dr = command.ExecuteReader();
while (dr.Read())
{
txname.Text = (dr["namep"].ToString());
txneshan.Text = (dr["neshanp"].ToString());
txidmeli.Text = (dr["idmeli"].ToString());
txdaraje.Text = (dr["daraje"].ToString());
connection.Close();
این موردا error میده : while (dr.Read())
این error : Invalid attempt to call Read when reader is closed.
من اینا نوشتم
SqlConnection connection = new SqlConnection();
connection.ConnectionString = @"Data Source=(local);Initial Catalog=khadamat;Integrated Security=True";
SqlCommand command = new SqlCommand("select namep,neshanp,idmeli,daraje from personel1 where id='" + txid.Text + "'", connection);
connection.Open();
SqlDataReader dr = command.ExecuteReader();
while (dr.Read())
{
txname.Text = (dr["namep"].ToString());
txneshan.Text = (dr["neshanp"].ToString());
txidmeli.Text = (dr["idmeli"].ToString());
txdaraje.Text = (dr["daraje"].ToString());
connection.Close();
این موردا error میده : while (dr.Read())
این error : Invalid attempt to call Read when reader is closed.