用C#实现ASP的添加方法,帮帮忙!
我想用C#实现象ASP中的
rs.addnew
rs( "a ") = "aaa "
rs( "b ") = 123
rs.update
这样方法添加数据,问一下,要怎么做啊?
------解决方案--------------------嗯 把分给我吧 谢谢
string dbPath = "../App_data/WebSeven.mdb ";
string db = Server.MapPath(dbPath);
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + db;
string strSQL = "SELECT [Svn_title],Svn_Content FROM [Svn_Product] ";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, conn);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds, "List ");
//记录的更新
// DataRow dr = ds.Tables[ "List "].Rows[1];
//
// dr.BeginEdit();
// dr[ "CustomerID "] = "******** ";
// dr[ "Address "] = "------ ";
// dr.EndEdit();
//记录更新也可写成这样!
// ds.Tables[ "List "].Rows[1].BeginEdit();
// ds.Tables[ "List "].Rows[1][ "CustomerID "] = "+++++ ";
// ds.Tables[ "List "].Rows[1][ "Address "] = "------ ";
// ds.Tables[ "List "].Rows[1].EndEdit();
//记录的插入
DataRow dr = ds.Tables[ "List "].NewRow();
dr[ "Svn_Title "] = "1242354554656 ";
dr[ "Svn_Content "] = "mmnnvbc ";
ds.Tables[ "List "].Rows.Add(dr);
//记录删除
// ds.Tables[ "List "].Rows[2].Delete();
//更新到数据库
da.Update(ds, "List ");
//DataGrid1.DataSource = ds.Tables[ "List "].DefaultView;
//DataGrid1.DataBind();
ds.Clear();
conn.Close();