7/9/2004

.Net DB Work should not be so complicated

Filed under: General — russell @ 4:00 am

Database work in .Net may seem complicated. If you are like me and use many of the great .Net info sites like www.asp.net and www.4guysfromrolla.com to "figure out" how to do this stuff, you may find that database work requires a little bit of indirection. To me this seemed powerful because of the benefits of abstraction, but did not live up to the marketed "simplicity" touted by Microsoft.

Here is a sample of how to do the DB work easily (bypassing the dataAdapter, that you often see in samples).

Code:
'Get Data From Products Table
'****************************
Dim sConn As New System.Data.SQL.SQLConnection("server=localhost;uid=sa;pwd=;database=northwind")
Dim sCmd As New System.Data.SQL.SQLDataSetCommand("SELECT ProductName FROM Products",sConn)
Dim ds As New System.Data.DataSet
	
'Fill The DataSet
'****************
sCmd.FillDataSet(ds,"Products")