DAAB 3.1 uses notes

xiaoxiao2021-03-06  35

I believe that many people have used Microsoft Data Application Blocks, in the previous version (before 3.0), it is implemented through the SQLHELPER class. It is necessary to use the SQLServer database. If you use other databases, you need to rewrite one, very troublesome, PetShop3.0 Just write an ORAHELPER to implement an Oracle database, this situation is no longer available in version 3.1.

You can go to GotdotNet download, the specific address doesn't remember.

DAAB3.1 End of NameSpace also changed: gotdotnet.ApplicationBlocks.Data implements SQLServer, Oracle, OLEDB, ODBC different types of connections through a general class ADOHELPER, automatically selects the appropriate database connection class by ADOHELPER to connect, when you are in different When you switch between database, you can implement the transformation of the database only if the configuration file does not change the code.

You can configure this in the configuration file:

As long as you use (VB)

Dim adohelper as adohelper = adohelper.createhelper ("misapp")

You can create an instance of AdoHelper. If the database is changed to Oracle, simply modify the connection string in the configuration file, and change the DAABPROVIDERS section to the following. If you are using a standard SQL statement, you don't need it. Any modification.

If you do not use an alias, you must specify the database type when instantiation AdoHelper, such as (VB):

DIM SQLHELPER As adohelper = adohelper.createhelper (gettype (sqlserver) .assembly.fullname, gettype (sqlserver) .fullname)

or

DIM SQLHELPER As adohelper = adohelper.createHelper ("GotdotNet.ApplicationBlocks.Data, GotdotNet.ApplicationBlocks.Data.sqlserver)

The next use is very simple (C #, ASPNETPAGER example), Private Void Page_Load (Object Sender, System.EventArgs E)

{

Adohelper helper = adohelper.createhelper ("misapp");

String connString = system.configuration.configurationSettings.Appsettings ["connString"];

IF (! page.ispostback)

{

ASPNETPAGER1.Recordcount = (int) helper.executescalar (connString, system.data.commandtype.text, "select count (*) from orderers);

Binddata ();

}

}

void binddata ()

{

Adohelper helper = adohelper.createhelper ("misapp");

String connString = system.configuration.configurationSettings.Appsettings ["connString"];

IdataParameter [] Para = new iDataParameter [2];

Para = helper.getspparameters (ConnString, "MyPager");

// mypager is a stored procedure for acquiring paging data

Para [0] .value = aspnetpager1.pageSize;

Para [1] .value = aspnetPager1.currentpageindex;

DataGrid1.datasource = helper.executeRead (ConnString, "MyPager", Para);

DataGrid1.databind ();

}

Public void aspnetpager1_pagechanged (Object src, wuqi.webdiyer.pagechangedeventargs e)

{

AspnetPager1.currentpageIndex = E.NewpageIndex;

Binddata ();

}

Above this code can be changed to Oracle's application without any modifications (the stored procedures in the database are still changed, the configuration file is changed)

Data Access Application Block 3.1 download address:

http://www.gotdotnet.com/Workspaces/releases/viewuploads.aspx?id=c20d12b0-af52-402b-9b7c-aaeb21d1f431

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

New Post(0)