Hi friends,
Please can you`ll help me
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Nov 8, 2011, 2:19 PM
Datta KharadPosted Nov 8, 2011, 7:46 AM
You can try this code...
private void button2_Click(object sender, EventArgs e)
{
DataSet ds=new DataSet();
DataSet dsData = new DataSet();
DataTable dt=new DataTable();
DataTable dtData = new DataTable();
SqlDataReader dr=null;
SqlDataReader drData = null;
object objData;
objData = MethodCall(ds, "DATASET");
dsData = (DataSet)objData;
objData = MethodCall(dt, "DATATABLE");
dtData = (DataTable)objData;
objData = MethodCall(dr, "DATAREADER");
drData = (SqlDataReader)objData;
}
private object MethodCall(object obj, string senderType)
{
DataSet dsTemp=new DataSet();
DataTable dtTemp = new DataTable();
SqlDataReader drTemp ;
object resObj=null;
if (senderType == "DATASET")
{
dsTemp = (DataSet)obj;
//Here your code
//==========
resObj = dsTemp;
}
else if(senderType=="DATATABLE")
{
dtTemp = (DataTable)obj;
//Here your code
//==========
resObj = dtTemp;
}
else if (senderType == "DATAREADER")
{
drTemp = (SqlDataReader)obj;
//Here your code
//==========
resObj = drTemp;
}
return resObj;
}
If you got correct solution then mark as Accepted Answer.
Nethra R SPosted Nov 8, 2011, 6:17 AM
How to write a method that returns a datareader object, same way to return dataset,datatable object. Can you tell me how to write the code for that?
Datta KharadPosted Nov 8, 2011, 5:53 AM
Describe your question in detail i,e what do you want?