luckie
asked on
Add C++ Variables into mySQL
What is the syntax of adding C++ variables into mySQL?
Could anyone raise an example?
I've tried
insert into aTable (field1, field2) values (variable1, variable2)
But mySQL throws error messages at me saying varible1 is not in the field list.
Thanks for your attention
Jack
Could anyone raise an example?
I've tried
insert into aTable (field1, field2) values (variable1, variable2)
But mySQL throws error messages at me saying varible1 is not in the field list.
Thanks for your attention
Jack
ASKER
Hi madwax,
Are you sure? :)
'var2' inserts the string 'var2' into the database, not the its variable representation
It returns duplicate entry right after the second insert.... :)
Thanks
Jack
Are you sure? :)
'var2' inserts the string 'var2' into the database, not the its variable representation
It returns duplicate entry right after the second insert.... :)
Thanks
Jack
ASKER
int var2 = 3;
Insert into table1 (field1, field2) values (var2, 'hello')
Insert into table1 (field1, field2) values (var2, 'hello')
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay. Thanks a lot :)
ASKER
Wait a minute... I've got a question...:O
How come when the field and the variables are both of type integer, why do you need to convert them into varchars. As in my database, they are of integer types.
Thanks for any attempt for solving my question
Jack
How come when the field and the variables are both of type integer, why do you need to convert them into varchars. As in my database, they are of integer types.
Thanks for any attempt for solving my question
Jack
ASKER
rc = SQLExecDirect (hstmt, (SQLCHAR *) "INSERT INTO aTable (a,b,... ) values (var1, '10', '', '', '', '', '', '', '', '','', '', c);", SQL_NTS);
mystmt (hstmt, rc);
where var1 is already a character pointer (C String)
and c is a stored procedure containing binary data.
Thanks
mystmt (hstmt, rc);
where var1 is already a character pointer (C String)
and c is a stored procedure containing binary data.
Thanks
//madwax