PDA

View Full Version : مشکل در مورد DataReader



mahdi5121
چهارشنبه 29 تیر 1390, 23:15 عصر
سلام ...
این کد ، کجاش اشکال داره ؟


try
{
con = new SqlConnection("Data Source=localhost;Initial Catalog=Test;Integrated Security=True");
}
catch (SystemException ex)
{
MessageBox.Show(ex.Message);
}


try
{
strSql = "SELECT Name FROM Person";
com = new SqlCommand(strSql, con);

con.Open();
SqlDataReader Reader = com.ExecuteReader();

dataGridView1.Rows.Add(Reader.GetValue(0).ToString ());

con.Close();
}
catch (SystemException ex)
{
MessageBox.Show(ex.Message);
}