Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Sorry if this is in the wrong area, but this has been buggin me since I started learning VB.NET.

 

In most books I read, and even in the study guides for MCAD/MCSD, when it comes to ADO.NET, they all seem to press you into using the visual tools to create the connections, commands, adapters and the datasets. Now I know for the exams I will want to learn these methods, but when creating real world applications, should the proper way be to design your own classes and build all of the above in code, or use the visual studio to do these tasks.

 

Sorry if this is a topic that has been beating down into the ground.

"Nobody knows what I do until I stop doing it."
  • *Experts*
Posted

I use the "visual" approach to get things going (figure out those darned complicated connection strings) and for test projects. In a "real" product, you would normally have a better strategy for sharing connections or not using them at all (some kind of DB layer, generally on a webserver for example).

 

As for commands, adapters, etc. - there's only one issue I'm aware of. The commands that are auto-generated will use the column directly such as "SELECT FirstName, LastName...". If you have reserved words in your column names, you'll need to change this to "SELECT [FirstName], [LastName], ...".

 

Again, in a "real" product, you're likely to have masked the use of adapters and commands in some kind of DB layer. For example, a simple class might expose a GetDataSet method that takes the name of a proc (with no params) that returns the DataSet.

 

This type of hiding is ideal since it hides the connection, database, etc. and just gets you back your data. Microsoft has an "Application Block" that you might want to look at:

http://www.microsoft.com/downloads/details.aspx?FamilyID=f63d1f0a-9877-4a7b-88ec-0426b48df275&displaylang=en

 

It's like a framework or recommended practice for setting up database objects.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
Thanks for the link and the comments. Just trying to learn how I SHOULD be working with database access on a more real world scale.
"Nobody knows what I do until I stop doing it."

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...