<%@ Page %>
<%@Import namespace="System.Data"%>
<%@Import namespace="System.Data.SqlClient"%>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection myConn=new SqlConnection("Server=localhost;Database=Pubs;UID=user;PWD=password");
SqlDataAdapter myAdapter=new SqlDataAdapter("SELECT au_id, au_lname, au_fname, contract FROM Authors WHERE au_lname LIKE 'Green%' ORDER BY au_lname", myConn);
DataTable myTable=new DataTable();
DataRow myRow;
SqlCommandBuilder myBuilder;
myAdapter.Fill(myTable);
myTable.Rows[0]["au_fname"]="Newname";
myTable.Rows[1].Delete();
myRow=myTable.NewRow();
myRow["au_id"]="123-45-6789";
myRow["au_fname"]="first";
myRow["au_lname"]="last";
myRow["contract"]=0;
myTable.Rows.Add(myRow);
myBuilder=new SqlCommandBuilder(myAdapter);
myAdapter.Update(myTable);
}
</script>
|