0

Hello People.

I would like to ask you're assistance with a little problem I am having. When I execute this code:

string sql2 = "INSERT INTO worlds (worlds_ID,worlds_active,worlds_name,worlds_x,worlds_y) VALUES ('', '1', 'Test', '250', '250');";
MySqlCommand cmd = new MySqlCommand(sql2, OpenCon());
addtolog("server", "World Created");

it does not make the new row in the databse, but it does execute the addtolog command.
Also the OpenCom() is not the problem, because it works fine with a SELECT query. I suspect that the problem lies with the query.

Could someone please tell me what is wrong with the code?

Thanks in advance :)
Dirk

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by dirkleonschut
1

You aren't executing the command at all. You're defining it and adding the SQL statement and the connection but you also need to add

cmd.ExecuteNonQuery();

to make the command actually affect the database. I'm assuming you have the opened the connection as well.

0

Thank you very much for your reply. How can I be such a stupic person not to realise I didn't actually execute it xD

Well, back to coding :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.