|
ITWriting.com |
A simple VB.Net database example
|
|||
|
|
||||
|
I like VB.Net, and in particular I much prefer the ADO.Net database API to ADO or DAO in VB 6.0 and earlier. Having said that, if you open up Visual Basic .Net for the first time and try to build a database application, it's not obvious how to proceed. To make matters worse, the data form wizard is not particularly helpful. Therefore, in Visual Programming Hands On, March 2004 edition, I gave a small example. It's one of many, many ways to create a database application, it's very short, it needs more error handling, and there are better and more sophisticated approaches you could take. However, it does split the data access from the presentation. One of the advantages is that you can re-use your data access DLL behind an ASP.Net web application, on an intranet or on the Internet. That's why I made Sub New in the SchoolData class take a path in its constructor. Just have your web app pass it the path to your MDB on the web server - probably somewhere not directly accessible from the Web. Or you can use some other database server. Most ASP.Net sites offer SQL Server. April 2004: Now added New and Delete buttons to complete a very simple application. Here's an example using the same data access DLL behind a web application. Of course it's not only data access that you can use behind both web apps and Windows forms apps. Build all your non-visual code into a separate assembly; that way you have maximum flexibility for future deployment. Copyright Tim Anderson 18th January 2004. All rights reserved. |
||||