[My ASP.NET learning course] DataAdapter operation (2)

xiaoxiao2021-03-06  59

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";

DataSet DS = New Dataset ();

OLEDBCONNECTION CONN = New OLEDBCONNECTION (Connectionstring);

OLEDBCOMMAND CMD = New OLEDBCOMMAND (STRSQL, CONN);

OLEDBDataAdapter Da = New OLEDBDataAdapter ();

// link database operations through the Command

Da.selectCommand = CMD;

Da.fill (DS, "Testmdb");

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

DataGrid1.databind ();

}

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

New Post(0)