Help with ADO and vc++-newbie [modified]
-
Hi everyone i'm trying to update a record of a db in access using ADO and the SQL update command the columns in the db are: token - text Spam - number Ham - number Pos - number (with decimal points) app- number in my program i have the following variables for each of the columns _bstr_t token; int valField2; int valField3; double valField4; int valField5; i try this code but i get an error at runtime pCommand->ActiveConnection = m_pConn; command="UPDATE tblDictionary SET Spam="+vlaField2; command+=",Pos="+valField4; command+=",app="+valField5; command+="WHERE token='"+ token; command+="'"; _bstr_t strSQLstatment=command.c_str(); variant_t vntRecordAffected; m_pConn->Execute(strSQLstatment,&vntRecordAffected,adCmdText); i get the following error Error:¦¨¨m¨V //i have no idea what this means but this is what i get if i try to update with spacific numbers instead of using variables it works fine pCommand->ActiveConnection = m_pConn; command="UPDATE tblDictionary SET Spam=10,Pos=0.43,app=10 WHERE token='"+ token; command+="'"; Any ideas what might be wrong. Do i need to convert all variables that are to be inserted to type _bstr_t; Please help me i really need to find this out thanks a lot
-
Hi everyone i'm trying to update a record of a db in access using ADO and the SQL update command the columns in the db are: token - text Spam - number Ham - number Pos - number (with decimal points) app- number in my program i have the following variables for each of the columns _bstr_t token; int valField2; int valField3; double valField4; int valField5; i try this code but i get an error at runtime pCommand->ActiveConnection = m_pConn; command="UPDATE tblDictionary SET Spam="+vlaField2; command+=",Pos="+valField4; command+=",app="+valField5; command+="WHERE token='"+ token; command+="'"; _bstr_t strSQLstatment=command.c_str(); variant_t vntRecordAffected; m_pConn->Execute(strSQLstatment,&vntRecordAffected,adCmdText); i get the following error Error:¦¨¨m¨V //i have no idea what this means but this is what i get if i try to update with spacific numbers instead of using variables it works fine pCommand->ActiveConnection = m_pConn; command="UPDATE tblDictionary SET Spam=10,Pos=0.43,app=10 WHERE token='"+ token; command+="'"; Any ideas what might be wrong. Do i need to convert all variables that are to be inserted to type _bstr_t; Please help me i really need to find this out thanks a lot
Can you log the strSQLstatment just before passing to the execute method.
suhredayan
There is no place like 127.0.0.1 -
Can you log the strSQLstatment just before passing to the execute method.
suhredayan
There is no place like 127.0.0.1 -
Thanks for the reply suhredayan® i'm sorry i'm not very good with ADO what to you mean by log the strSQLstatment? thanks again
antonaras wrote:
i'm sorry i'm not very good with ADO what to you mean by log the strSQLstatment
Can you print the the content of strSQLstatment somewhere and see any problem with the it before passing to the Execute method.
suhredayan
There is no place like 127.0.0.1 -
Hi everyone i'm trying to update a record of a db in access using ADO and the SQL update command the columns in the db are: token - text Spam - number Ham - number Pos - number (with decimal points) app- number in my program i have the following variables for each of the columns _bstr_t token; int valField2; int valField3; double valField4; int valField5; i try this code but i get an error at runtime pCommand->ActiveConnection = m_pConn; command="UPDATE tblDictionary SET Spam="+vlaField2; command+=",Pos="+valField4; command+=",app="+valField5; command+="WHERE token='"+ token; command+="'"; _bstr_t strSQLstatment=command.c_str(); variant_t vntRecordAffected; m_pConn->Execute(strSQLstatment,&vntRecordAffected,adCmdText); i get the following error Error:¦¨¨m¨V //i have no idea what this means but this is what i get if i try to update with spacific numbers instead of using variables it works fine pCommand->ActiveConnection = m_pConn; command="UPDATE tblDictionary SET Spam=10,Pos=0.43,app=10 WHERE token='"+ token; command+="'"; Any ideas what might be wrong. Do i need to convert all variables that are to be inserted to type _bstr_t; Please help me i really need to find this out thanks a lot
-
antonaras wrote:
i'm sorry i'm not very good with ADO what to you mean by log the strSQLstatment
Can you print the the content of strSQLstatment somewhere and see any problem with the it before passing to the Execute method.
suhredayan
There is no place like 127.0.0.1Hey suhredayan® thanks for the reply when i output the strSQLstatement i get: ictionary SET Spam=,Pos=☺s=WHERE token='pill'//is totally messed up Error:Θ·╒ Press any key to continue and the output of strSQLstatment when i use fixed numbers looks good UPDATE tblDictionary SET Spam=10,Pos=0.43,app=10 WHERE token='pill' Press any key to continue Can u see why this happens cause i have no clue thanks again
-
Since
valField
variables are of integer type, expressions like",Pos=" + valField4
seem to be problematic. Do you see the error when you compile the program, or when the program runs? -
Hey suhredayan® thanks for the reply when i output the strSQLstatement i get: ictionary SET Spam=,Pos=☺s=WHERE token='pill'//is totally messed up Error:Θ·╒ Press any key to continue and the output of strSQLstatment when i use fixed numbers looks good UPDATE tblDictionary SET Spam=10,Pos=0.43,app=10 WHERE token='pill' Press any key to continue Can u see why this happens cause i have no clue thanks again
-
-
Hi everyone i'm trying to update a record of a db in access using ADO and the SQL update command the columns in the db are: token - text Spam - number Ham - number Pos - number (with decimal points) app- number in my program i have the following variables for each of the columns _bstr_t token; int valField2; int valField3; double valField4; int valField5; i try this code but i get an error at runtime pCommand->ActiveConnection = m_pConn; command="UPDATE tblDictionary SET Spam="+vlaField2; command+=",Pos="+valField4; command+=",app="+valField5; command+="WHERE token='"+ token; command+="'"; _bstr_t strSQLstatment=command.c_str(); variant_t vntRecordAffected; m_pConn->Execute(strSQLstatment,&vntRecordAffected,adCmdText); i get the following error Error:¦¨¨m¨V //i have no idea what this means but this is what i get if i try to update with spacific numbers instead of using variables it works fine pCommand->ActiveConnection = m_pConn; command="UPDATE tblDictionary SET Spam=10,Pos=0.43,app=10 WHERE token='"+ token; command+="'"; Any ideas what might be wrong. Do i need to convert all variables that are to be inserted to type _bstr_t; Please help me i really need to find this out thanks a lot
antonaras wrote:
_bstr_t strSQLstatment=command.c_str();
Set a breakpoint here. What is the value of
command
?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb