using IDBConnection to create an IDataAdapter with C++

  • Thread starter Thread starter Jeronimo Bertran
  • Start date Start date
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
 
Hi Jeronimo,

I am performing further research basoed on this issue and will get back to
you with some suggestions lately.

Have a great weekend

Sincerely,

Kevin
Microsoft Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! - www.microsoft.com/security

--------------------
| Content-Class: urn:content-classes:message
| From: "Jeronimo Bertran" <[email protected]>
| Sender: "Jeronimo Bertran" <[email protected]>
| Subject: using IDBConnection to create an IDataAdapter with C++
| Date: Wed, 20 Aug 2003 12:23:23 -0700
| Lines: 40
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNnUIYET9RvirkRT26mRNDFwyKr3A==
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:58806
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| 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
|
|
 
Back
Top