Jump to content
Xtreme .Net Talk

Recommended Posts

  • Administrators
Posted

You could always call the DataTable's .Rows.Add method to load data into the DataTable.

If you returned a DataReader from a database you could simply loop through all the returned records and add them manually - although this is pretty much what the DataAdapter does anyway.

Is there a particular reason you want to avoid using a DataAdapter?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • Administrators
Posted
Nearly always, if the provided adapter (SqlDataAdapter, OleDbDataAdapter etc.) don't do exactly what you want then it's worth considering implementing your own (not that difficult - inherit from System.Data.Common.DataAdapter and override the required methods). Doing it this way prevents you duplicating the same create connection, command, open connection, run command, loop & add to table, close connection logic in several places - you do it once in the DataAdapter and can call it with a simple .Fill method everywhere else.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

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...