PDA

View Full Version : MSQL Access without Data Binding


voxecho
02-07-2009, 07:10 PM
Hello all -

Before I become Control Dependent, i would like to understand how Database Access and Direct manipulation of data in ASP.NET is achieved.

I am having trouble finding anything that addresses this with SQL Server (express) and was hoping someone here could help me.

in Classic ASP i would create a connection using server.createObject("ADODB.Connection") and then a RecordSet object to which i would feed a query string and if there are returns i could step through them with a

Do While Not RS.Eof
Loop

I've found some info on connecting to MySql DB which allows me similar (if more hoop jumping) access but how do i do this with MS Sql?

- Also, while on the topic, with MySql there is a DataReader object which allows me to loop through, but i can't seem to access the information by way of field name, only index. is this my only option?

Thank you in Advance
-Echo

demtron
02-07-2009, 09:19 PM
First, take a look at http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx on MSDN Online. Depending on your needs, you'll want to look at the SqlConnection, SqlDataReader, SQLDataAdapter, and SQLCommand classes. One major difference in .Net is that, with the exception of the DataReader, all data is collected into a disconnected memory dataset so as not to consume server resources by leaving a data stream open for a long time. This does take a little getting used to.

Regarding the field name reference, see http://msdn.microsoft.com/en-us/library/f01t4cfy.aspx. I have never had a problem with this kind of access. If you're still stuck, post some code and we'll see what we can do.

voxecho
02-08-2009, 05:53 PM
thank you - that's what i finally figured out myself. the links on getting field names are very helpful.

-Echo