Hello Guys I am learning new things from a book and today as I wanted to test the code that I wrote. I received that error:
MySql.Data.MySqlClient.MySqlException: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com, 'Bmw0308)' at line 1"
I don't know how to fix it its a program for registration with email and password and I am using a Console Application (.Net Framework) for it and yeah can someone help me? :D
Here is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace Datenbank1
{
class Program
{
static void Main(string[] args)
{
string daten = "SERVER = localhost;" +
"DATABASE = db;" +
"UID = Sarper;" +
"PASSWORD = Bmw03082009;";
Console.Write("E-Mail: ");
string email = Console.ReadLine();
Console.Write("Password: ");
string password = Console.ReadLine();
MySqlConnection con = new MySqlConnection(daten);
string command = "INSERT INTO Daten VALUES (" +
email + ", '" +
password + ");";
MySqlCommand execute = new MySqlCommand(command);
execute.Connection = con;
con.Open();
execute.ExecuteNonQuery();
con.Close();
}
}
}