Paramterized insert into syntax error.

I can't tell what error I have in the syntax.

Everything seems smooth, but when I try to execute non query it gives me the error incorrect syntax near @username.

using (SqlConnection c = new SqlConnection(connect))
        {
            c.Open();
            using (SqlCommand cm = new SqlCommand(cm1,c))
            {
                #region parametrii
                //cm.CommandType = CommandType.Text;
                cm.Parameters.AddWithValue("@nickname",nicktext.Text);
                cm.Parameters.AddWithValue("@nume",numetext.Text);
                cm.Parameters.AddWithValue("@prenume",prenumetext.Text);
                cm.Parameters.AddWithValue("@parola",passtext.Text);
                if (Msex.Checked == true)
                {
                    cm.Parameters.AddWithValue("@sex", Msex.Text);
                }
                else
                {
                    cm.Parameters.AddWithValue("@sex", Fsex.Text);
                }
                cm.Parameters.AddWithValue("@mailadress",mailtext.Text);
                cm.Parameters.AddWithValue("@judet",judettext.Text);
                cm.Parameters.AddWithValue("@oras",orastext.Text);
                cm.Parameters.AddWithValue("@adresa",adresatext.Text);

                #endregion
                cm.ExecuteNonQuery();
            }
            c.Close();
        }

The connection and command strings:

string connect = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Raul\Documents\Visual Studio 2010\Projects\Db Try\Db Try\Database1.mdf;Integrated Security=True;User Instance=True";
    string cm1 = "insert into Information Values @nickname,@nume,@prenume,@parola,@sex,@mailadress,@judet,@oras,@adresa";

Answers


You have missed parentheses for values in insert query

Just try this

string connect = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Raul\Documents\Visual Studio 2010\Projects\Db Try\Db Try\Database1.mdf;Integrated Security=True;User Instance=True";
    string cm1 = "insert into Informatii Values (@nickname,@nume,@prenume,@parola,@sex,@mailadress,@judet,@oras,@adresa)";

Need Your Help

How can I capture bitmap data very quickly in C#

c# performance bitmap system.drawing

My goal is to be able to take a row of 70 pixels, analyze all 70 pixels for a certain kind of color, and then throw to another function if criteria are met. This needs to happen at least once ever...

Passing parameters to stored procedure for an UPDATE

c# sql asp.net sql-server

I've been trying to convert to using stored procedures in SQL Server to do our CRUD. In my code-behind here, this is how I pass the parameters to the SqlHelper class (If you need to me to post this...