ADO???????????????鷽??
???????????? ???????[ 2014/9/28 10:35:35 ] ????????????? ADO
????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();
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11