<%@ Page Language= "C# " %>
<%@Import Namespace= "System.Data "%>
<%@Import Namespace= "System.Data.OleDb "%>
<Script runat= "server ">
void Page_Load(Object Src, EventArgs E) {
OleDbConnection Conn=new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0; "+
"Data Source= "+Server.MapPath( "person.mdb "));
Conn.Open();
string strSQL= "select * from grade; ";
OleDbDataAdapter da=new OleDbDataAdapter(strSQL, Conn);
DataSet ds = new DataSet();
da.Fill(ds, "grade ");
DataTable dt = ds.Tables[ "grade "];
DataRow row = dt.NewRow();
row[ "学号 "] = "199 ";
row[ "姓名 "] = "小布什 ";
row[ "数学 "] = 58;
dt.Rows.Add(row);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
da.Update(ds, "grade ");
dg.DataSource = ds.Tables[ "grade "].DefaultView;
dg.DataBind();
Conn.Close();
}
</script>
<ASP:DataGrid id= "dg " runat= "server "/>
书上说 “OleDbCommandBuilder cb = new OleDbCommandBuilder(da)”的功能是对新加的数据行进行转换,但是我看不懂,敬请高手指点,谢谢
------解决方案--------------------------------------------------------
沙发,帮忙顶