I have this code which should connect to a MS Access database and output the string values of "table´".. Well see for yourself
I can compile it okey, but with one warning:Code:#include <stdio.h> #include "E:\Program Files\Microsoft Visual Studio\VC98\mfc\SRC\stdafx.h" #import "c:\program files\common files\system\ado\msado15.dll" rename("EOF", "EOFile") struct StartOLEProcess { StartOLEProcess() { ::CoInitialize(NULL); } ~StartOLEProcess() { ::CoUninitialize(); } } _start_StartOLEProcess; int main() { ADODB::_ConnectionPtr Con = NULL; ADODB::_RecordsetPtr RecSet = NULL; ADODB::FieldPtr pStrings; _variant_t vStrings; char sStrings[150]; HRESULT hr = S_OK; VARIANT *RecordsAffected = NULL; hr = Con.CreateInstance(__uuidof(ADODB::Connection)); printf("\nCreateInstance result=%d uuidof=%d\n", hr, __uuidof(ADODB::Connection)); printf("\nConnection object created."); Con->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\database.mdb", "", "password", 0); printf("\nConnection opened..."); RecSet = Con->Execute("SELECT * FROM strings", RecordsAffected, 1); printf("\nSQL statement processed"); pStrings = RecSet->Fields->GetItem(Table); printf("\nGetting data now...\n"); while(!RecSet->EOFile) { vStrings.Clear(); vStrings = pQuestions->Value; WideCharToMultiByte(CP_ACP, 0, vStrings.bstrVal, -1, sStrings, sizeof(sStrings), NULL, NULL); printf("\n%s", sStrings); RecSet->MoveNext(); } printf("\n\nEnd of data.."); RecSet->Close(); RecSet = NULL; printf("\nClosed and removed recordset object."); Con->Close(); Con = NULL; printf("\nClosed and removed connection object."); return 0; }
so it compiles okey, and then when I try to run the program, the following output comes:Code:Compiling... main.cpp d:\c++\database\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned Linking... database.exe - 0 error(s), 1 warning(s)
Does somebody have a solution to my problem?Code:D:\C++\database\Debug>database.exe CreateInstance result=0 uuidof=1300 Connection object created. This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
Thx in advance![]()



LinkBack URL
About LinkBacks



