Hello everyone.
Im trying to create a cmd application in VS2010 C++,in which i will read some integer values and insert them into a table in MS SQL server. For the connection of the application with the server i use ODBC.
If i use something like the following, i get results (insert is working):
if(SQL_SUCCESS!=SQLExecDirect(sqlstatementhandle,(SQLCHAR*)"INSERT INTO MyTable(value1) VALUES (111)", SQL_NTS)){
show_error(SQL_HANDLE_STMT, sqlstatementhandle);
}
after the execution of the code above if i check the database i can see that insert worked just fine. Can someone tell me how i can use variables in the insert query, instead of numbers(like 111 above)?
Also since i couldnt find the proper syntax of insert with integer variables, i tried to create a stringstream(concatenating the insert command with the integer variables), which i later convert to string and use it in my sql command. Unfortunately it doesnt work either!
I think this definitely is no C++/CLI question, so this is the wrong forum section here. It doesn't seem to really be concerned with native C++ either, so I think the best place to ask is the Database section.
At any rate, welcome to CodeGuru!
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Thank you Eri523
I'll try to be more careful in the future!
Originally Posted by Eri523
I think this definitely is no C++/CLI question, so this is the wrong forum section here. It doesn't seem to really be concerned with native C++ either, so I think the best place to ask is the Database section.
Bookmarks