• Welcome to Valhalla Legends Archive.
 

[ASP .NET] OleDbDataReader

Started by CupHead, November 12, 2003, 11:03 AM

Previous topic - Next topic

CupHead

As a precursor to developing my application on an SQL server, I'm working out the bugs and data access stuff locally using Access databases and reading them with the OleDbDataReader object.  Currently, to access data, the code looks something like:

(Database has one table, two columns, both are strings.

Do While MyReader.Read()
 TempString = MyReader.GetString(0)
 TempString2 = MyReader.GetString(1)
Loop


Is there any way to access the columns by name like we used to like:


 TempString = MyRecordSet.Fields("Username").Value


And when I move things to an SQL server, are my data access functions going to change?

quasi-modo

#1
yes, the syntax of sql statements should change somewhat for you, but it looks like you are using c# so I would not know how. I use c# but not often.
btw you are going to need to change this
<%@ Import Namespace="System.Data.OLEDB" %>
to this
<%@ Import Namespace="System.Data.SqlClient" %>
hope this helps :)
WAR EAGLE!
Quote(00:04:08) zdv17: yeah i quit doing that stuff cause it jacked up the power bill too much
(00:04:19) nick is a turtle: Right now im not paying the power bill though
(00:04:33) nick is a turtle: if i had to pay the electric bill
(00:04:47) nick is a turtle: id hibernate when i go to class
(00:04:57) nick is a turtle: or at least when i go to sleep
(00:08:50) zdv17: hibernating in class is cool.. esp. when you leave a drool puddle