Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have created a class to handle all my database I/O. I have set up a method to pass in sql statements in that class and I'm hoping to get that method to return a recordset object.

 

How can I return a recordset object to my calling class?

 

( am I even approaching this correctly? , thanks for your consideration )

Posted
public DataTable GetData(string sql)
{
// get connection, execute sql, whatever
// eg. DataTable dt = WhatEverMethod();

return dt;
}

 

thanks for that quick reply. So what about on my original class part? Do I have to create a datatable in that as well and then fill it with the returned object?

Posted
thanks for that quick reply. So what about on my original class part? Do I have to create a datatable in that as well and then fill it with the returned object?

Yep, with something like this

 

 

DataTable dt = obj.GetData("Select * from myTable");

There is no spoon. <<The Matrix>>

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