ahmad000012
یک شنبه 04 دی 1390, 12:02 عصر
در دستورا زیر برای نمایش نتیجه جستجو خطای زیر را مشاهده می کنم
The SelectCommand property has not been initialized before calling 'Fill'.
که برای دستور da.Fill(dt); است
SqlConnection objConnection = new
SqlConnection("Server=localhost;Database=anbar;integrated security=true;");
SqlCommand objCommand = new SqlCommand();
objCommand.Connection = objConnection;
objCommand.CommandText = "Select * from employ where emid='"+txtfamily.Text+"'";
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
objConnection.Open();
da.Fill(dt);
dataGridView.DataSource = dt;
objConnection.Close();
The SelectCommand property has not been initialized before calling 'Fill'.
که برای دستور da.Fill(dt); است
SqlConnection objConnection = new
SqlConnection("Server=localhost;Database=anbar;integrated security=true;");
SqlCommand objCommand = new SqlCommand();
objCommand.Connection = objConnection;
objCommand.CommandText = "Select * from employ where emid='"+txtfamily.Text+"'";
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
objConnection.Open();
da.Fill(dt);
dataGridView.DataSource = dt;
objConnection.Close();