دوست عزيز اين نمونه كد را امتحان كن ببين چي كار مي كنه؟
private void button2_Click(object sender, EventArgs e)
{
try
{
SqlDataAdapter da = new SqlDataAdapter(sqlCommand1.CommandText, sqlConnection1.ConnectionString);
DataSet ds = new DataSet();
SqlDataReader reader;
da.Fill(ds, "bimar");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "bimar";
sqlCommand1.Connection.Close();
sqlCommand1.CommandText = "select * from bimar where namebimar=" + "'" + comboBox7.Text + "'" + "and codepersonal=" + "'" + textBox1.Text + "'";
sqlCommand1.Connection.Open();
reader = sqlCommand1.ExecuteReader();
while (reader.Read() == true)
{
textBox7.Text = (string)reader["codepersonal"];
textBox3.Text = (string)reader["family"];
textBox4.Text = (string)reader["namebimar"];
break;
}
}
catch (Exception)
{
MessageBox.Show("چنين بيماري وجود ندارد");
}
}