C++ and ADO problem
-
Hi again I hava a problem again executing an sql statment(INSERT) in my program can anyone help me find whats wrong?
hr = S_OK; CoInitialize(NULL); try { _ConnectionPtr m_pConn; HRESULT hr =m_pConn.CreateInstance(__uuidof(Connection)); if (FAILED( hr )) cout<<"Can't create an intance of ADO.Connection"<Open(_bstr_t("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =ADOTestDB.MDB"), _bstr_t( "" ), _bstr_t( "" ), adModeUnknown ))) cout<<"Can't open datasource"<//The program works up to here then it gives me an error:0x m_pConn->Execute(strSQL,NULL,adExecuteNoRecords); printf("Data Added Successfully\n",(LPCSTR)strSQL); m_pConn->Close(); }catch( _com_error &ce ) { printf("Error:%s\n",ce.Description); } CoUninitialize();
I wrote the program almost the same way as the sample code but still is not working the fiels in the db are DeptID: number Name: Text OfficeNo: number Phone: text DeptHead: text Any ideas? thanks a lot for all the help you gave me so far -
Hi again I hava a problem again executing an sql statment(INSERT) in my program can anyone help me find whats wrong?
hr = S_OK; CoInitialize(NULL); try { _ConnectionPtr m_pConn; HRESULT hr =m_pConn.CreateInstance(__uuidof(Connection)); if (FAILED( hr )) cout<<"Can't create an intance of ADO.Connection"<Open(_bstr_t("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =ADOTestDB.MDB"), _bstr_t( "" ), _bstr_t( "" ), adModeUnknown ))) cout<<"Can't open datasource"<//The program works up to here then it gives me an error:0x m_pConn->Execute(strSQL,NULL,adExecuteNoRecords); printf("Data Added Successfully\n",(LPCSTR)strSQL); m_pConn->Close(); }catch( _com_error &ce ) { printf("Error:%s\n",ce.Description); } CoUninitialize();
I wrote the program almost the same way as the sample code but still is not working the fiels in the db are DeptID: number Name: Text OfficeNo: number Phone: text DeptHead: text Any ideas? thanks a lot for all the help you gave me so farI Think, u r going wrong in framing the Insert Statement.
antonaras wrote:
printf("%s\n",(LPCSTR)strSQL);
What is the output of the above line ??? Appu.. "If you judge people, you have no time to love them."
-
I Think, u r going wrong in framing the Insert Statement.
antonaras wrote:
printf("%s\n",(LPCSTR)strSQL);
What is the output of the above line ??? Appu.. "If you judge people, you have no time to love them."
-
I Think, u r going wrong in framing the Insert Statement.
antonaras wrote:
printf("%s\n",(LPCSTR)strSQL);
What is the output of the above line ??? Appu.. "If you judge people, you have no time to love them."
-
Hey NiceNaidu i got it you where right there was a problem with framing the values of the inser statment thanks for helping me out
Ok fine..keep going Appu.. "If you judge people, you have no time to love them."
-
Hi again I hava a problem again executing an sql statment(INSERT) in my program can anyone help me find whats wrong?
hr = S_OK; CoInitialize(NULL); try { _ConnectionPtr m_pConn; HRESULT hr =m_pConn.CreateInstance(__uuidof(Connection)); if (FAILED( hr )) cout<<"Can't create an intance of ADO.Connection"<Open(_bstr_t("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =ADOTestDB.MDB"), _bstr_t( "" ), _bstr_t( "" ), adModeUnknown ))) cout<<"Can't open datasource"<//The program works up to here then it gives me an error:0x m_pConn->Execute(strSQL,NULL,adExecuteNoRecords); printf("Data Added Successfully\n",(LPCSTR)strSQL); m_pConn->Close(); }catch( _com_error &ce ) { printf("Error:%s\n",ce.Description); } CoUninitialize();
I wrote the program almost the same way as the sample code but still is not working the fiels in the db are DeptID: number Name: Text OfficeNo: number Phone: text DeptHead: text Any ideas? thanks a lot for all the help you gave me so far