VB.NET / SQL 2K - Best Coding Practice? [RESOLVED]
Hi all,
I've been a VB developer since as long as I can remember (im only 24 :P) and our company has decided to make the inevitable transition into .net
On and off I have spent the last year using ASP.net with SQL server in an effort to learn T-SQL but I've picked up on a lot of the .net features.
I'm now developing my first VB.net app using SQL server 2k as the data store. I've decided to put the mountain of dll's I've made from VB6 including all the db-handlers to one side and start a fresh.
Anyway, I've constructed a small database, and altho I have found myself replicating the structure in .net in the form of classes, everything looks structured until I want to essentially suck the data from SQL into the class. In asp.net, I've always dropped a SqlDataAdapter linked to an sqlcommand onto a component so all the db code is created for me and I've never had a prob with that.
Now that Im creating a class, I can't drop sqldataadapters on, and I point blank refuse to believe I have to generate all that evil code (that the component would normally do) manually. The reason Im using classes instead of components is I want to use inhertitance and as a component already inherits from System.ComponentModel.Component, I cant use it.
I know this is a larrrrge ramble (even for meh :bigyello:) but any pro's or know-it-alls :D out there who can gimme some advice on what you think is best way on how to read/write from classes to sql-server using sqlcommand objects, would be much appreciated.
An ISBN number would be fine also lol :-)
Thanks
Re: VB.NET / SQL 2K - Best Coding Practice?
Quote:
Originally posted by tailz
In asp.net, I've always dropped a SqlDataAdapter linked to an sqlcommand onto a component so all the db code is created for me and I've never had a prob with that.
Bad practice. Why? It just is!
Quote:
... I point blank refuse to believe I have to generate all that evil code (that the component would normally do) manually.
You will have to.
The reason the drag-drop method is discouraged is because you learn very little from it.
Use the SQLClient namespace's classes to implement the functionality in your class. It'll be painful at first, all that typing, but in the end, it's worth it. :)