Problem with Query statement

Hey guys

I want to insert values into a MySql database. The following line works fine:
1
2
3

mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')"); 

but if the data to be inserted is from a string... like....

1
2
string NewTitle = "Monaco";
string NumofShows = "2";


How do i edit my sql statements so variables can be inserted into the Values ( ) , and it will be able to read the variables and then store it into the database.
you need to create string that has the same key words as in your example,
and then call
 
mysql_query(connection, myQuery.c_str());

where
myQuery it's your created string
What do u mean by same keyword? could you show me how is it done based on the example i gave?
http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html#intro

Look at how positional parameters are used in prepareStatement().
I am not very clear about it. Could you show me how is it done on my example?
Topic archived. No new replies allowed.