Let me preface by saying Im not really a C programmer. More of a vb programmer doing .net stuff, but someone got word i did a little c back in college some 10 years ago and threw this at me. so im not really comfortable or sure i know what im doing.
they are trying to connect to an oracle database we have here. using that data source, username, and pass in the connstring i can connect to the database using sql+. The code they gave me was a mess, so ive cleaned it up a bit and finally got it to compile. it crashes on the pConnection->Open line, and my catch message simple says "Invalid Pointer". Ive found a lot of very similar code on the net so I know im not doing anything too unordinary. Any ideas or can someone please point me in the right direction?
Thanks
Code:#include <iostream> #include <stdio.h> #include <windows.h> #import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile") //#include "c:\oracle\ora92\oo4o\CPP\include\ORACL.H" //#include "c:\oracle\ora92\oledb\include\oraoledb.h" using namespace std; void main() { HRESULT hr = S_OK; _ConnectionPtr pConnection = NULL; _bstr_t strCnn("Provider=OraOLEDB.Oracle;PLSQLRSet=1;USER Id=UPTS_TEST;Password=UPTS_TEST;Data Source=DVLP9;"); try { /* create an instance of connection object */ //TESTHR (pConnection.CreateInstance(__uuidof(Connection))); /* open the connection */ hr = pConnection.CreateInstance(__uuidof(Connection)); cout << "before connect\n"; hr = pConnection->Open(strCnn,"","",adConnectUnspecified); cout << "after connect\n"; if (hr == S_OK) cout << "connected\n"; else cout << "not connected\n"; pConnection->Close(); } catch(_com_error &ce) { printf("Description = %s\n", (char*) ce.ErrorMessage()); } }



LinkBack URL
About LinkBacks



