[My ASP.NET Learning History] DataAdapter operation (1)

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

DataSet DS = New Dataset ();

OLEDBCONNECTION CONN = New OLEDBCONNECTION (Connectionstring);

OLEDBDataAdapter Da = New OLEDBDataAdapter (strsql, conn);

/ / Link database operation via the Connection

Da.fill (DS, "Testmdb");

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

DataGrid1.databind ();

}

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

New Post(0)