V
Vaap
I am trying to get dataset working through IDbDataAdapter interface as
my solution need to work with Sql Server and Oracle ODP. I am using
different data provider factories and the code here only shows SQL
Server.
My code snippets are
// Build the interface in provider factory (_pf in code below)
public IDbDataAdapter CreateDataAdapter()
{
return (IDbDataAdapter) new SqlDataAdapter();
}
....
Instantiate the class using reflection depending upon data provider
factory selection through web.config
//
....
public IDbDataAdapter DataAdapter = null;
public void prepareDataSet(string SQL)
{
connect();
DataAdapter = _pf.CreateDataAdapter();
DataAdapter.SelectCommand = _pf.CreateCommand(SQL,_connection);
}
I use this method from data access layer class to fill the dataset.
public DataSet GetContactAuth(DataSet ds)
{
string sql = "SELECT * FROM contact_auth";
db.prepareDataSet(sql);
db.DataAdapter.Fill(ds);
return ds;
}
I call this method from my business layer
public DatasetContactAuth execute(string userName, string password)
{
DatasetContactAuth dsLogin = null;
try
{
connectToDb();
ContactDAL dal = new ContactDAL(getDb());
dsLogin = (DatasetContactAuth) dal.GetContactAuth(new
DatasetContactAuth());
disconnectFromDb();
}
catch(Exception e)
{
ExceptionManager.Publish(e);
this.ErrorMsg = "Error in getting Contact information. Please
contact your system administrator.";
}
return dsLogin;
}
The Problem :
If I use typed dataset and use direct SQLClient API then I have to use
Fill(ds,"Table_name") to fill the dataset. Fill(ds) alone does not
work.
The IDbDataAdapter interface has only one overloaded method of Fill as
against 7 or more available in DBDataAdapter in System.Data.Common.
I am at loss to figure this out. Is there something, you can point out
to help me.
My requirements:
1. I have to use typed datasets. Weak datasets are not an option.
2. I have to use Interfaces to make code work with different data
providers.
How do I fill my typed dataset under this condition using
IDbDataAdapter interface.
I am new to .net so please pardon my ignorance.
I appreciate your help.
-Regards.
my solution need to work with Sql Server and Oracle ODP. I am using
different data provider factories and the code here only shows SQL
Server.
My code snippets are
// Build the interface in provider factory (_pf in code below)
public IDbDataAdapter CreateDataAdapter()
{
return (IDbDataAdapter) new SqlDataAdapter();
}
....
Instantiate the class using reflection depending upon data provider
factory selection through web.config
//
....
public IDbDataAdapter DataAdapter = null;
public void prepareDataSet(string SQL)
{
connect();
DataAdapter = _pf.CreateDataAdapter();
DataAdapter.SelectCommand = _pf.CreateCommand(SQL,_connection);
}
I use this method from data access layer class to fill the dataset.
public DataSet GetContactAuth(DataSet ds)
{
string sql = "SELECT * FROM contact_auth";
db.prepareDataSet(sql);
db.DataAdapter.Fill(ds);
return ds;
}
I call this method from my business layer
public DatasetContactAuth execute(string userName, string password)
{
DatasetContactAuth dsLogin = null;
try
{
connectToDb();
ContactDAL dal = new ContactDAL(getDb());
dsLogin = (DatasetContactAuth) dal.GetContactAuth(new
DatasetContactAuth());
disconnectFromDb();
}
catch(Exception e)
{
ExceptionManager.Publish(e);
this.ErrorMsg = "Error in getting Contact information. Please
contact your system administrator.";
}
return dsLogin;
}
The Problem :
If I use typed dataset and use direct SQLClient API then I have to use
Fill(ds,"Table_name") to fill the dataset. Fill(ds) alone does not
work.
The IDbDataAdapter interface has only one overloaded method of Fill as
against 7 or more available in DBDataAdapter in System.Data.Common.
I am at loss to figure this out. Is there something, you can point out
to help me.
My requirements:
1. I have to use typed datasets. Weak datasets are not an option.
2. I have to use Interfaces to make code work with different data
providers.
How do I fill my typed dataset under this condition using
IDbDataAdapter interface.
I am new to .net so please pardon my ignorance.
I appreciate your help.
-Regards.