<% @ Import Namespace = "System. data "%> <% @ Import Namespace =" System. data. sqlClient "%> <scriptrunat =" server "> voidPage_Load (object sender, System. eventArgs e) {SqlConnection conn = new SqlConnection ("server = localhost; uid = sa; pwd =; database = db"); SqlDataAdapter da = new SqlDataAdapter (); sqlCommand cmd = new SqlCommand ("select Id AS id, Name AS name from table", conn); DataSet ds = new DataSet (); conn. open (); da. selectCommand = cmd; da. fill (ds, "table"); for (int I = 0; I <ds. tables ["table"]. rows. count; I ++) {Response. write (ds. tables ["table"]. rows [1] + "<br>") ;}for (int I = 0; I <ds. tables ["table"]. rows. count; I ++) {ds. tables ["table"]. rows. beginEdit (); ds. tables ["table"]. rows [1] = "***********"; ds. tables ["table"]. rows. endEdit ();} String strUpdateSql = "Update table set Name = @ name where Id = @ id"; cmd = new SqlCommand (strUpdateSql, conn); cmd. parameters. add ("@ id", SqlDbType. int, 4, "id"); cmd. parameters. add ("@ name", SqlDbType. char, 10, "name"); da. updateCommand = cmd; da. update (ds, "table"); ds. acceptChanges (); conn. close () ;}</script> The following is an example of insert: <% @ Import Namespace = "System. data "%> <% @ Import Namespace =" System. data. sqlClient "%> <scriptrunat =" server "> voidPage_Load (object sender, System. eventArgs e) {// create a DataTable data source Dt able Dt = new DataTable (); DataRow Dr; Dt. columns. add (new DataColumn ("name"); for (int j = 0; j <3; j ++) {Dr = Dt. newRow (); Dr [0] = "name" + j. toString (); Dt. rows. add (Dr);} SqlConnection conn = new SqlConnection ("server = localhost; uid = sa; pwd =; database = db"); SqlDataAdapter da = new SqlDataAdapter (); // create InsertCommand StringBuilder sb = new StringBuilder (""); sb. append ("INSERT table (Name) VALUES ("); sb. append ("@ name)"); da = Dt. newRow ();. insertCommand = new SqlCommand (); da. insertCommand. commandText = sb. toString (); da. insertCommand. connection = conn; SqlParameter sp = new SqlParameter ("@ name", SqlDbType. varChar, 40); sp. sourceVersion = DataRowVersion. current; sp. sourceColumn = "name"; // or sp. sourceColumn = Dt. columns [0]. columnName; da. insertCommand. parameters. add (sp); // Update operation da. update (Dt); conn. close () ;}</script>