Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I am trying to figure out how to best program a part of a new .NET site I am working on. Sadly, due to a medical issue, I haven't been able to get back into programming for the past three years, and it seems that some of my .NET mojo has been way too lazy. <sigh>

 

So, I have a SQL connection in my ASP.NET application working, and can use some of the built in tools to see the records in the database. But, what I really want is to put the results of my query into some form of recordset where I can assign results into different variables so I can use them within the application.

 

Kind of like retrieving a different variable for each requested field inside the SQL Server record returned.

 

What is the best way to accomplish this? I seem to be barking up the wrong tree in the efforts I have made so far.

 

Thank you,

 

Derek C.

Posted

You probably want to look into the DataSet object, it is the .NET version of a RecordSet.

 

Once you populate the DataSet, you access it like this:

 

foreach(DataRow dr in dsObject.Tables["tableName"].Rows)
{
   int yourVariable = int.Parse(dr["fieldName"].ToString());
}

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

  • 3 weeks later...
Posted

You can also populate a sqldatareader. I have had much success with it.

 

It seems to take a long time to fill a dataset/datatable. Especially if you have no intentions of editing the returned dataset.

Go Beavs!!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...