Hey! I am making a program that keeps track of users so the program has to update the number in the database how do I actually do it? I know how to select things and such, but have no idea how the update works.. I didn't really find anything for c++ in google :S. Thanks in advance.
Silvershaft
2
Junior Poster
Recommended Answers
Jump to PostTake a look at this example MySQL query
UPDATE my_table SET password = '111111' WHERE id = '5'
or
UPDATE my_table SET point = point+1000 WHERE rank > '0'
I hope this answers your question :)
Jump to PostIt should work. Are you sure you are connected to your database with a user allowed to manipulate users?
If you retrieve the error message, it would be easier to determine :)
Jump to PostThat's supposed to mean everything went ok, afaik :)
Maybe if you try not incrementing, instead set the value to something? Just to make sure we can do something.
res = stmt->executeQuery("UPDATE users SET usersactive = '10'");
Jump to PostI got only one entry and one column in my table so would I do like this
stmt = con->createStatement(); res = stmt->executeQuery("UPDATE users SET usersactive = usersactive+1");
This isn't working.. What do I do wrong
Maybe this is finally missing:
res = stmt->executeQuery("COMMIT");
It's always …
Jump to PostSounds strange. You could just ignore the exception, but that would not be too correct.
I really don't know, haven't used the C++ MySQL library before, only in C, Ruby and PHP.
All 22 Replies
Excizted
67
Posting Whiz
Silvershaft
2
Junior Poster
Excizted
67
Posting Whiz
Silvershaft
2
Junior Poster
Excizted
67
Posting Whiz
Silvershaft
2
Junior Poster
tesuji
135
Master Poster
Silvershaft
2
Junior Poster
Excizted
67
Posting Whiz
tesuji
135
Master Poster
Silvershaft
2
Junior Poster
tesuji
135
Master Poster
Silvershaft
2
Junior Poster
tesuji
135
Master Poster
Silvershaft
2
Junior Poster
tesuji
135
Master Poster
tesuji
135
Master Poster
Silvershaft
2
Junior Poster
tesuji
135
Master Poster
Silvershaft
2
Junior Poster
tesuji
135
Master Poster
Silvershaft
2
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.