Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
goodhell
Starting Member
1 Post |
Posted - 2008-05-24 : 13:52:02
|
hello.Iam developing a application. I want to connect to SQL server 2005 by ADO in C++. I use COM model to connect. But when I run application, it's error: Runtime error. This application has requested to the Runtime to terminal it in an unusual away. Please contact.... who know, help me.here is my code: ::CoInitialize(NULL); _ConnectionPtr pConnection = NULL; _RecordsetPtr pRecordset = NULL; _bstr_t strCnn("Provider=sqloledb;Data Source='nguyenanhkien';Initial Catalog='company';User ID = kien;Password=123;"); pConnection.CreateInstance(__uuidof(Connection)); pConnection->Open(strCnn, "", "",adConnectUnspecified); pRecordset.CreateInstance(__uuidof(Recordset)); pRecordset->Open("Accountant",_variant_t((IDispatch *) pConnection, true),adOpenKeyset,adLockOptimistic,adCmdTable); _bstr_t strQuery("Select * from NhanVien"); pRecordset->Open( strQuery, _variant_t ((IDispatch*)pConnection), adOpenStatic, adLockReadOnly, adCmdText); long id= long ( pRecordset->GetCollect("id")); printf("id: %d", id); //close database pRecordset->Close(); pConnection->Close(); ::CoUninitialize();Nguyen Anh Kien |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-05-24 : 13:56:08
|
You can test sql connection in odbc on that machine. |
|
|
|
|
|
|
|