Can ADO(not ADO.net) be used in C++/CLR windows form application?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
Im migrating from VC6 to VC2010.
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
After I created a C++/CLR windows form application, I added following in stdafx.h:
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
#import "c:program filescommon filessystemadomsado15.dll" no_namespace rename("EOF","adoEOF")
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
when I use ADO in form, for example as follows:
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
_ConnectionPtr pConnection;<br/>
HRESULT hr1, hr2; <br/>
hr1 = pConnection.CreateInstance("ADODB.Connection");<br/>
<strong style="border:0px; font-style:inherit; font-family:inherit; margin:0px; outline:0px; padding:0px hr2 = pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=./inf/AppConfig.xls;Extended Properties="Excel 8.0;HDR=YES;IMEX=1"","","",adModeUnknown);
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
}
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left

<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
The exception is thrown when It is running:
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
Exception: _CrtIsValidHeapPointer(pUserData)
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
I am sure the bold line causes this exception, but whats the problem? Can I use ADO in this situation?
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px; text-align:left
Thanks!

View the full article
 
Back
Top