I’m trying to INSERT
data into my SQL
database but its not showing anything at all.
This is a for an online role-playing game . There is no error but when I refresh my browser for phpmyadmin
using XAMP
, no data is being shown.
MySqlConnection connection = new MySqlConnection(connectionString);
connection.Open();
string checkDatabase = "select * from players where username = @playerName";
MySqlCommand command = new MySqlCommand(checkDatabase, connection);
command.Parameters.AddWithValue("@playerName", player.SocialClubName);
MySqlDataReader reader = command.ExecuteReader();
if(reader.Read())
{
player.SendChatMessage("There is an account with the assiociated Social Club Profile!");
}
else
{
MySqlConnection connection1 = new MySqlConnection(connectionString);
connection1.Open();
string playerInsert = "insert into players(username,password) VALUES (@user,@password)";
MySqlCommand command1 = new MySqlCommand(playerInsert, connection1);
command1.Parameters.AddWithValue("@user", player.SocialClubName);
command1.Parameters.AddWithValue("@password", password);
connection1.Close();
}
connection.Close();
2
Answers
That’s cause you are not executing the query at all as can be seen in below posted code
You need to execute the query. Try: