user319824
user319824

Reputation:

sending query over c++

I have the following data stored in string ;

string name = "gokera atoram"

And, I want send this using sql command in c++

mysql_query ( ... , ? ) ;

What should I write to the place marked with '?' ?

command :

insert into Names values ( name );

EDIT:

further information, I take data from standart input

cin >> name mysql_query ( ..., ? )

if I write like "insert ... ( name ) ", name will be treated as string not as variable name .

Upvotes: 0

Views: 280

Answers (1)

CloudyMarble
CloudyMarble

Reputation: 37566

Take a look at the documentation. It says:

int mysql_query(MYSQL *mysql, const char *stmt_str)

Description

Executes the SQL statement pointed to by the null-terminated string stmt_str. Normally, the string must consist of a single SQL statement and you should not add a terminating semicolon (“;”) or \g to the statement. If multiple-statement execution has been enabled, the string can contain several statements separated by semicolons.

I guess this example could be helpful

Upvotes: 1

Related Questions