J
Jeronimo Bertran
I am using ADO.NET base classes to reduce code forking
depending on the Data Provider.
I have a global IDBConnection (m_connection) created in
the following manner:
if (m_nDataProvider == SqlClient)
{
strConnection = S"Server=localhost;Integrated
Security=true;Database=Quanto";
SqlConnection* connection = new SqlConnection
(strConnection);
m_connection = connection;
}
else
{
strConnection = S"Provider=SqlOledb.1;Data
Source=localhost;Integrated Security=true;Database=Quanto";
OleDbConnection* connection = new OleDbConnection
(strConnection);
m_connection = connection;
}
Now I want to use that connection to create an adapter:
IDataAdapter* adapter;
if (m_nDataProvider == SqlClient)
adapter = new SqlDataAdapter(str, m_connection);
else
adapter = new OleDbDataAdapter(str, m_connection);
But I am unable to perform a typecast from IDBConnection
to the appropiate connection class.
Thanks,
Jeronimo Bertran
depending on the Data Provider.
I have a global IDBConnection (m_connection) created in
the following manner:
if (m_nDataProvider == SqlClient)
{
strConnection = S"Server=localhost;Integrated
Security=true;Database=Quanto";
SqlConnection* connection = new SqlConnection
(strConnection);
m_connection = connection;
}
else
{
strConnection = S"Provider=SqlOledb.1;Data
Source=localhost;Integrated Security=true;Database=Quanto";
OleDbConnection* connection = new OleDbConnection
(strConnection);
m_connection = connection;
}
Now I want to use that connection to create an adapter:
IDataAdapter* adapter;
if (m_nDataProvider == SqlClient)
adapter = new SqlDataAdapter(str, m_connection);
else
adapter = new OleDbDataAdapter(str, m_connection);
But I am unable to perform a typecast from IDBConnection
to the appropiate connection class.
Thanks,
Jeronimo Bertran