Board index » cppbuilder » Any Help with thsi? Return status for SQL UPDATE call
Phillip Davis
![]() CBuilder Developer |
Any Help with thsi? Return status for SQL UPDATE call2004-11-22 09:05:17 PM cppbuilder36 Hello, I am using BCB 6 and MS SQL Server for my db application. I may want to migrate to another DB type later on, so I am staying away from SQL servers stored procedures. What I would like to know is how I can obtain the server status of the query that was sent for an update call.Below is the function I am working with, but I get a Error creating cursor handle message. Thanks, Phillip int __fastcall TDBForm::UpdateClientInfo(TCLIENTINFO *info) { int iRetCode = GOODRETCODE; // Query host session TQuery *Query = NULL; Query = new TQuery(Application); Query->DatabaseName = ALIASNAME; try { AnsiString SQLString = " DECLARE @error int UPDATE renterinfo SET LastName = 'Smith' where Phone = '800-555-1212' SELECT @error = @@ERROR"; //Clear any existing strings and initialize the insert sql object properties Query->SQL->Clear(); Query->SQL->Add(SQLString); // Query->ExecSQL(); Query->Open(); if (Query ->RecordCount == 0) iRetCode = BADRETCODE; else if (Query ->RecordCount>0) { int miSQLError = Query ->FieldByName("error")->AsInteger; if (miSQLError != 0) { iRetCode = BADRETCODE; } } } catch (Exception &exception) { iRetCode = BADRETCODE; ShowMessage(exception.Message.c_str()); } delete Query; return iRetCode; } |