[My ASP.NET Learning History] Database Settion (4)

xiaoxiao2021-03-06  56

Protected system.web.ui.webcontrols.dataGrid DataGrid1;

Private Void Page_Load (Object Sender, System.EventArgs E)

{

String dbpath = @ "DATA / DBTEST.MDB";

String DB = Server.mappath (dbpath);

String connectionString = "provider = microsoft.jet.Oledb.4.0; data source =" DB;

String strsql = "SELECT [CUSTOMERID], [Address] from [Customers]";

OLEDBCONNECTION CONN = New OLEDBCONNECTION (Connectionstring);

OLEDBDataAdapter Da = New OLEDBDataAdapter (strsql, conn);

OLEDBCommandbuilder CB = New OLEDBCommandbuilder (DA);

DataSet DS = New Dataset ();

Da.fill (DS, "List");

// Record update

// DATAROW DR = DS.TABLES ["List"]. Rows [1];

//

// Dr.BegineDit ();

// DR ["customerid"] = "********";

// DR ["Address"] = "------";

// Dr.Endedit ();

// Record update can also be written!

// ds.tables ["list"]. Rows [1] .beginedit ();

// ds.tables ["list"]. Rows [1] ["Customerid"] = " ";

// ds.tables ["list"]. Rows [1] ["Address"] = "------";

// ds.tables ["list"]. Rows [1] .endedit ();

// Record insertion

// DATAROW DR = DS.TABLES ["list"]. Newrow ();

// DR ["Customerid"] = "1242354554656";

// DR ["address"] = "mmnnvbc";

//

// ds.tables ["list"]. Rows.Add (DR);

// Record deletion

// ds.tables ["list"]. Rows [2] .delete ();

/ / Update to the database

Da.UPDATE (DS, "List");

DataGrid1.datasource = DS.TABLES ["list"]. DefaultView;

DataGrid1.databind ();

Ds.clear ();

CONN.CLOSE ();

}

转载请注明原文地址:https://www.9cbs.com/read-113634.html

New Post(0)