????1????????????System.Data.SqlClient?е?SQL Server??????
????2????SQL Server??????????????ADO.NET??Connection?????????????SQL Server??????????
????string connectionStr = "Data source=????????;Initial Catalog=?????????; uid=?????;pwd=????()";        //  ?????????????
????// Integrated Security=True    ??????????
????//uid=xxx;Pwd=xxx    ???????????
????SqlConnection connection1 = new SqlConnection(connectionStr);           ///?????Connection?????????????????
????connection1.Open();                                                                          ///???????????
????……………
????connection1.Close();                                                                         ///????????????
????3????SQL Server??????????????????????SqlCommand?????????????в???
??????1??????????????????
????SqlConnection connection1 = new SqlConnection(connectionStr);            //????????
????connection1.Open();                                                                            //???????????
????string sqlStr = "??SQL??????????  insert into A  values('abc'??1)??";       //??????????????????д??????
????SqlCommand command1 = new SqlCommand(sqlStr?? connection1);          //?????????????????????????????connection1??????????sqlStr ?????????????????
????command1.ExecuteNonQuery();                                                             //ExecuteNonQuery()????????????????????????????????????????ExecuteNonQuery()??????????????                                                                                                                           // UPDATE??INSERT??DELETE???????????????????????????
????connection1.Close();     ///????????????
???????1???????Course???пγ????003??????
string connectionStr = "Data source=.;Initial Catalog=Student; Integrated Security=True";
SqlConnection connections = new SqlConnection(connectionStr);
string sqlstr = "delete from Course where Cno='006' ";
SqlCommand command1 = new SqlCommand(sqlstr?? connectionss);
conn.Open();
if (command1.ExecuteNonQuery() > 0)
{
MessageBox.Show("????γ?????");
};
connections .Close();
???????2????Course???????????γ???γ????????????
string connectionStr = "Data source=.;Initial Catalog=Student;Integrated Security=True";
SqlConnection connection = new SqlConnection(connectionStr);
int Credit = Convert.ToInt32(txtCredit.Text); /TextBox.text??string?????????????????????“Convert.ToInt32”??string????????int????
string sqlStr = "insert into Course values('" + txtCno.Text + "'??'" + txtCname.Text + "'??" + Credit + ")";//???????????????????????????????????????????????????????????
//????????‘ “+?????????+” ’??????????“+???????+”
SqlCommand command1= new SqlCommand(sqlStr?? connection);
connection.Open();
if (command1.ExecuteNonQuery() > 0)
{
MessageBox.Show("?γ????????");
};
connection.Close();