Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Central Database Definition for all DB Controls and Actions

Status
Not open for further replies.

iaresean

Programmer
Mar 24, 2003
570
ZA
Hi All;

I am developing a generic ASP.NET 2 template site that we can use for as a base for our future applications. We previously used classic ASP.

My query is, is it possible for me to create a single database definition is a central location that all my controls and database classes can use to connect to a database. The reason for this is that we constantly switch between MSACCESS and MSSQL as a db based on demands.

In classic ASP this was easily done as we built a central connection string in an asp file that we could simply include on our pages. Therefore, if we made a change to this include page we could switch processing easily between an MSACCESS and MSSQL db.

Is a similiar approach possible with ASP.NET 2? I have been using GridView and OleDbReader to connect to a MSACCESS db. I noticed that C# has specific classes for MSSQL. Do I have to use this classes, or is there a generic database class which I can use to select/insert/update either an MSACCESS or MSSQL db?

Any and all recommendations/advice/help would be GREATLY appreciated!

Sean. [peace]
 
Use a Data Layer such as the Data Access Block from microdoft. That way, you can connect up to any database by changing one line in your web.config file...



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Hi ca8msm;

Thank you for the response! I was beginning to think I wasn't going to get one.

This data layer component sounds very promising! However, the link you provided talks about the Data Access Block being SQL Server specific. Have you used this component against an Access database before?

Thanks again.

Sean. [peace]
 
Yes, as far as I know it can can be used against most data sources by editing an entry in the web.config file. I haven't tried it against MS Access but I'm sure you could just try it and see what happens.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Great!

Will do, thanks. If all works out a star will be in order. ;-)

Thanks again.

Sean. [peace]
 
Actually, even if the current version doesn't support the database that you want to use, you'll simply be able to write your own layer for that type (the general idea of the block is to highlight how it can be used as a wrapper for any number of layers and therefore can support any database type). It may be that Microsoft have written a layer for SQL Server just for this demonstration and left it up to developers to add their own layers in if necessary.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi ca8msm,
This may sound stupid and silly. I downloaded this: compiled etc. I want to test this ... and am kind of stuck here....
please advise
 
raghu3, did you install the best practices library and not the component from the link above? If not, I would recommend doing so. It is a more up to date version. You can find the link in the page above.

I have also just started looking into this library. So far the documentation is extremely interesting. I found this in the Data Accss Application Block documentation area:

"ADO.NET 2.0 provides classes such as the DbCommand class and the DbConnection class; these classes help to abstract the data provider from any particular database implementation. The Data Access Application Block takes advantage of these classes and provides a model that further supports encapsulation of database type-specific features, such as parameter discovery and type conversions."

Interesting statement, when it comes to my requirements. Will definitely be doing some more research and experimentation. Will keep you all posted.

Sean. [peace]
 
I have installed the library: the link above points to an Enterprise Library june 2005 and the library has different components. I am going through the documentation as well.
I don't have ADO.NET 2. I am nut sure how to find this also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top