با سلام
من به جای کد خودم روشی که دوستان گفتن را امتحان کردم اما جواب نداد
این کد منه :
Fill DataGridView
using (SqlConnection Cn = new SqlConnection(ClassConnection.StrConn))
{
try
{
SqlCommand Cmd = new SqlCommand();
Cmd.Connection = Cn;
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.CommandText = "usp_FillDataGridView";
DataTable dt = new DataTable();
Cn.Open();
SqlDataReader dr = Cmd.ExecuteReader();
if (dr.HasRows)
{
dt.Load(dr);
}
dr.Close();
dataGridView1.DataSource = dt;
}
catch (SqlException ex)
{
MessageBox.Show("Error SQL : " + ex.Message);
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
}
finally
{
Cn.Close();
}
}
مشکل اینه که هر دفعه مجبورم این کد را فراخوانی کنم