Let me preface what I'd like to do: As a testbed for learning and eventually completely migrating to .NET, I'm converting a site from ASP to ASP.NET. At this point, the site merely consumes data as opposed to updating or adding data to the base tables. That said, I'd like to know how to do a few things just to get a kick start, and having a good code example would help me out a lot.
1) First off, I'd like to connect to an Access DB. Web Matrix has an Access Data Source Control
<wmx:AccessDataSourceContr
ol runat="server"></wmx:Acces
sDataSourc
eControl>
Unfortunately, there's no property sheet attached to this control, so I'm at a bit of a loss as to how to properly set properties.
2) Traditionally, I've pulled data from an Access DB (or actually even SQL Server or Oracle) similar to this method:
set conn = Server.CreateObject("ADODB
.Connectio
n")
conn.Open Application("dbConnectStri
ng")
sql = "select <fields> from <table> where <condition>"
set rs = conn.Execute(sql)
if NOT (rs.BOF and rs.EOF) then
arr = rs.GetRows()
rs.Close
set rs = nothing
end if
conn.Close
set conn = nothing
Response.Write "<table>"
for i = 0 to UBound(arr, 2)
Response.Write "<tr>"
'[write out the table cell information with CSS class assignments]
Response.Write "</tr>"
next
Response.Write "</table>"
Okay, pretty straight-forward. What is the equivalent to this in .NET? I'm assuming it's the DataReader object. Mind you, I don't want to use a data grid for this exercise because I want to know how to read optimally through a data set, capture its data in some fashion (as in the above example, I used a 2d array), then use whatever write directives I have at my disposal. Also, all the examples I've seen on the web employ the DataGrid; however, there are many instances where I don't even display the data, and need only parse the dataset for specific items.
In any case, sorry for taking so long with this explanation. I guess it simply boils down to this: Can you provide me with some code that will accomplish the following:
1) Connect to an Access DB
2) Read through the dataset without using the DataGrid.
Thanks!
GoofyDawg
Start Free Trial