04-22-2013 11:35 PM
hi,
could you please suggest how to insert data in to data base through variable, i have used code like this:
resCode = DBImmediateSQL(hdbc, "INSERT INTO table1(highlimit,lowlimit) VALUES (mes1,mes2)");
but i am getting error like too few parameters expected2. do i need to use another function for using variable.
Thanks & Regards
Solved! Go to Solution.
04-23-2013 01:42 AM
If you pass the string "INSERT INTO table1(highlimit,lowlimit) VALUES (mes1,mes2)", mes1 and mes2 are not subsituted with their values if they are variables. You need first to build the string you are passing to DBImmediateSQL e.g:
char sql_cmd[200];
sprintf (sql_cmd, "INSERT INTO table1(highlimit,lowlimit) VALUES (%f,%f)", mes1, mes2);
resCode = DBImmediateSQL(hdbc, sql_cmd);
You may have a look on this post with the same problem