Diesel Posted July 29, 2004 Posted July 29, 2004 Is there a way to load information from a database into a DataTable without using a DataAdapter? Quote
Administrators PlausiblyDamp Posted July 29, 2004 Administrators Posted July 29, 2004 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? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Diesel Posted July 29, 2004 Author Posted July 29, 2004 I was just wondering. Do you think using an Adapter would be the best way? Quote
Administrators PlausiblyDamp Posted July 29, 2004 Administrators Posted July 29, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.