Hello , I'm new in C# programming. I tried to do a simple console C# application which can simplify a
lot my daily work.
I want to execute a dynamic SQL query after connecting to database. Till now i've done data reading for all variables i need for sql query + finished dynamic connection to database.
"INSERT INTO test2 (id) values ('%u',id)" => That won't work sadly in this sittuation. Other method
to do ?
I want to execute a dynamic SQL query after connecting to database. Till now i've done data reading for all variables i need for sql query + finished dynamic connection to database.
Code:
used library : using MySql.Data.MySqlClient;
Code:
// setting up database connection string connectionString = "Server=" + Ip + ";Port=" + Port + ";Database=" + DatabaseName + ";Uid=" + Username + ";password=" + Password; MySqlConnection connection = new MySqlConnection(connectionString); // execute query command code MySqlCommand command = connection.CreateCommand(); command.CommandText = "INSERT INTO test2 (id) values ('%u',id)"; connection.Open(); command.ExecuteNonQuery(); connection.Close();