???????3????γ?“???????”?????????5??
string connectionStr = "Data source=.;Initial Catalog=Student; Integrated Security=True";
SqlConnection connection = new SqlConnection(connectionStr);
string sqlStr = "update Course set Ccredit=5 where Cname='???????'";
SqlCommand command1= new SqlCommand(sqlStr?? connection);
connection .Open();
if (command1.ExecuteNonQuery() > 0)
{
MessageBox.Show("??????????");
};
connection .Close();
??????2????????????ExecuteScalar??????????????????(Object)????????????е???е????
???????4????Student???в??????201244111???????????
string connectionStr = "Data source=.;Initial Catalog=Student;
Integrated Security=True";
SqlConnection connection = new SqlConnection(connectionStr);
string sqlstr = "select Sname from student where Sno='201244111' ";
SqlCommand command1 = new SqlCommand(sqlstr?? connection);
connection.Open();
string studentName = command1.ExecuteScalar().ToString();
MessageBox.Show(studentName);
connection.Close();
???????DataReader???????????????ж??????ζ????
???????5??????DataReader???ж???student???е?????????
string connectionStr = "Data source=.;Initial Catalog=Student;
Integrated Security=True"; SqlConnection connection = new SqlConnection(connectionStr);
string sqlstr = "select *from student";
SqlCommand command1 = new SqlCommand(sqlstr?? connection);
connection.Open();
SqlDataReader dataReader1 = command1.ExecuteReader();
// DataReader????й????????????????????????????Command?????command1??ExecuteReader()????
while (dataReader1.Read())  ///DataReader??Read()?????????????????????θ????DataReader??????????????????????β??????False???????True
{
MessageBox.Show(dataReader1[0].ToString());
}
connection.Close();
????4.???SqlDataAdapter???????????????????? ?????????????????????????????????е?????????????е???????????С?????????????????????????????????????佻??????
????????????????
????connection1.Open();      ///???????????
????string sqlStr = "SELECT * FROM A";                                                                ///??A????????????????SQL???
????SqlDataAdapter dataAdapter1 = new dataAdapter(sqlStr?? connection1);            ///???????dataAdapter1????????????????            ????????????connection1???SELECT???
????DataSet dataSet1 = new DataSet();                                                            ///???????dataSet1??????????? dataAdapter1.Fill(dataSet1);
????………………………………
????///???SqlDataAdapter???е?Fill()???????????????????У????SqlDataAdapter???е?Fill()??????Update()???????????????????????????????????
????connection1.Close();
???????6????Student???е???????????????
string connectionStr = "Data source=.;Initial Catalog=Student;
Integrated Security=True";
SqlConnection connection = new SqlConnection(connectionStr);
string sqlstr = "select *from student";
connection.Open();
SqlDataAdapter dataAdapter1 = new SqlDataAdapter(sqlstr?? connection);
DataSet dataSet1 = new DataSet();
dataAdapter1.Fill(dataSet1); ///???SqlDataAdapter???е?Fill()???????????????????У?????????????????
DataTable dt1 = dataSet1.Tables[0];
///???????????????
this.dataGridView1.DataSource = dt1;
connection.Close();