Saturday, February 1, 2014

how to implement the function in c#

I am converting the code form vb.net to c#.In vb.net if you pass typed dataset from entity to dataaccess haivng the untyped dataset it is accepting but in c# if you pass it is not accepting.through google i found one function i dont know how to implement.


I would like to implement the below Interface function:


int ExecuteDataAdapterDataTableWithParams(IDbCommand podbCommand, ref T pdtDataTable) whereenter code here` T : DataTable;



I would like to implement like mentioned below. I need both the number of rows and datatable.



public int ExecuteDataAdapterDataTableWithParams(IDbCommand podbCommand, ref DataTable pdtDT)
{
IDataAdapter ldaDataAdapter = default(IDataAdapter);
IDbTransaction lodbTrans = default(IDbTransaction);
int liFetchedRows = 0;
lodbTrans
= EstablishConnection();
try
{
podbCommand
.Connection = coConnection;
podbCommand
.Transaction = lodbTrans;
ldaDataAdapter
= GetDataAdapter(ref podbCommand);
ldaDataAdapter
.TableMappings.Add("Table", pdtDT.TableName);
liFetchedRows
= ldaDataAdapter.Fill(pdtDT.DataSet);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
CloseConnection(ref lodbTrans);
}
return liFetchedRows;
}



No comments:

Post a Comment