Variable value in SQL Query
-
Hi! I've to insert a value to a column in a particular data base table on a Button Click Event. I write the following statement to execute this:
SQLdb.Query("INSERT INTO Current(TeamID) values('countryId')");
countryId is an int value. I've printed and verified it. But when the click event happens and if I open the database and check for the corresponding column, only "countryId" is present(variable's name not the variable value as I expect). If I give countryId without single quotes in the statement also the result is the same. What to do to store the variable's value in to the database? -
Hi! I've to insert a value to a column in a particular data base table on a Button Click Event. I write the following statement to execute this:
SQLdb.Query("INSERT INTO Current(TeamID) values('countryId')");
countryId is an int value. I've printed and verified it. But when the click event happens and if I open the database and check for the corresponding column, only "countryId" is present(variable's name not the variable value as I expect). If I give countryId without single quotes in the statement also the result is the same. What to do to store the variable's value in to the database? -
Preferably using parameterised queries, but as I don't know what
SQLdb
is, I cant show you what code to use. However the SQL query would look likeINSERT INTO Current(TeamID) values (@countryId)
Hi! I'm using Sqlite. I'm calling Sqlite from C++.
-
Hi! I've to insert a value to a column in a particular data base table on a Button Click Event. I write the following statement to execute this:
SQLdb.Query("INSERT INTO Current(TeamID) values('countryId')");
countryId is an int value. I've printed and verified it. But when the click event happens and if I open the database and check for the corresponding column, only "countryId" is present(variable's name not the variable value as I expect). If I give countryId without single quotes in the statement also the result is the same. What to do to store the variable's value in to the database?Try:
SQLdb.Query("INSERT INTO Current(TeamID) values(' + countryId + ')");
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
Try:
SQLdb.Query("INSERT INTO Current(TeamID) values(' + countryId + ')");
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
Now + countryId + is store in the table.
-
Now + countryId + is store in the table.
Oops - sorry, should have been:
SQLdb.Query("INSERT INTO Current(TeamID) values(" + countryId + ")");
Couldn't you have figured that out on your own?"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
Oops - sorry, should have been:
SQLdb.Query("INSERT INTO Current(TeamID) values(" + countryId + ")");
Couldn't you have figured that out on your own?"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
Sorry! I'm a C++ Programmer. I'm new to SQL. That's why I'm troubling you again and again. This Query is also not working. C++ shows error: C2110:Can not add two pointers.
modified on Friday, July 30, 2010 7:23 AM
-
Sorry! I'm a C++ Programmer. I'm new to SQL. That's why I'm troubling you again and again. This Query is also not working. C++ shows error: C2110:Can not add two pointers.
modified on Friday, July 30, 2010 7:23 AM
That's as close as I can get you. I haven't used C++ for years but I'm pretty sure you could create a string object with the id inserted and pass that to the query. You must know how to do that, surely.
printf
orsprintf
, if I recall."If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
Sorry! I'm a C++ Programmer. I'm new to SQL. That's why I'm troubling you again and again. This Query is also not working. C++ shows error: C2110:Can not add two pointers.
modified on Friday, July 30, 2010 7:23 AM
-
Hi! I've to insert a value to a column in a particular data base table on a Button Click Event. I write the following statement to execute this:
SQLdb.Query("INSERT INTO Current(TeamID) values('countryId')");
countryId is an int value. I've printed and verified it. But when the click event happens and if I open the database and check for the corresponding column, only "countryId" is present(variable's name not the variable value as I expect). If I give countryId without single quotes in the statement also the result is the same. What to do to store the variable's value in to the database?I suggest you tell your boss to hire an SQL specialist.