returning a recordset to a calling class.

protoculture

Member
Joined
May 5, 2005
Messages
9
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 Im 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 )
 
Code:
public DataTable GetData(string sql)
{
	// get connection, execute sql, whatever
	// eg. DataTable dt = WhatEverMethod();

	return dt;
}
 
michael_hk said:
Code:
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?
 
protoculture said:
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


Code:
DataTable dt = obj.GetData("Select * from myTable");
 
Back
Top