ajaygargqaz
July 7th, 2009, 08:01 AM
Hi all.
I am a beginner in ADO, and am trying to write a very basic program to connect to a sqlserver using ADO in C++. The sqlserver uses windows authentication.
I have followed the internet steps to create "connect.udl". I have been able to create the connection string, and "Test Connection" works like a charm.
Now, when I try to use this file in my ADO-C++ program in Visual Studio 2003, the error "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." error is shown, just when the _ConnectionPtr tries to do a "open" on the database.
Here is my code :::
///////////////////////////////////////////////// CODE - Begin ///////////////////////////////////////////
#include<iostream>
#import "c:\program files\common files\system\ado\msado15.dll" rename ("EOF","ADOEOF") no_namespace
using namespace std;
int main(int argc, char *argv[])
{
_ConnectionPtr connection;
_CommandPtr pCommand;
_ParameterPtr pParameter;
_RecordsetPtr recordset;
int iErrorCode;
HRESULT hr;
hr = connection.CreateInstance(__uuidof(Connection));
if(hr)
{
cout << "Connection obtained" << "\n";
}
hr = recordset.CreateInstance(__uuidof(Recordset));
if(hr)
{
cout << "RecordSet created" << "\n";
}
cout << "About to open connection" << "\n";
connection->Open(L"File Name=E:\connect.udl;", L"", L"", adConnectUnspecified);
cout << "open connection opened" << "\n";
recordset->Close();
}
///////////////////////////////////////////////// CODE - End ///////////////////////////////////////////
The output is :::
///////////////////////////////////////////////// OUTPUT - Begin ///////////////////////////////////////////
Connection obtained
RecordSet created
About to open connection
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Press any key to continue
///////////////////////////////////////////////// OUTPUT - End ///////////////////////////////////////////
I will be grateful of any enlightenment.
I am a beginner in ADO, and am trying to write a very basic program to connect to a sqlserver using ADO in C++. The sqlserver uses windows authentication.
I have followed the internet steps to create "connect.udl". I have been able to create the connection string, and "Test Connection" works like a charm.
Now, when I try to use this file in my ADO-C++ program in Visual Studio 2003, the error "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." error is shown, just when the _ConnectionPtr tries to do a "open" on the database.
Here is my code :::
///////////////////////////////////////////////// CODE - Begin ///////////////////////////////////////////
#include<iostream>
#import "c:\program files\common files\system\ado\msado15.dll" rename ("EOF","ADOEOF") no_namespace
using namespace std;
int main(int argc, char *argv[])
{
_ConnectionPtr connection;
_CommandPtr pCommand;
_ParameterPtr pParameter;
_RecordsetPtr recordset;
int iErrorCode;
HRESULT hr;
hr = connection.CreateInstance(__uuidof(Connection));
if(hr)
{
cout << "Connection obtained" << "\n";
}
hr = recordset.CreateInstance(__uuidof(Recordset));
if(hr)
{
cout << "RecordSet created" << "\n";
}
cout << "About to open connection" << "\n";
connection->Open(L"File Name=E:\connect.udl;", L"", L"", adConnectUnspecified);
cout << "open connection opened" << "\n";
recordset->Close();
}
///////////////////////////////////////////////// CODE - End ///////////////////////////////////////////
The output is :::
///////////////////////////////////////////////// OUTPUT - Begin ///////////////////////////////////////////
Connection obtained
RecordSet created
About to open connection
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Press any key to continue
///////////////////////////////////////////////// OUTPUT - End ///////////////////////////////////////////
I will be grateful of any enlightenment.