SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\project\Projects\labelnameinsecondformtry\labelnameinsecondformtry\Database1.mdf;Integrated Security=True;User Instance=True"; SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; conn.Open(); try { cmd.CommandText = "Insert into Table2 values (username)"; cmd.Parameters.Add("@username", SqlDbType.VarChar).Value =textBox1.Text; cmd.ExecuteNonQuery(); } finally { conn.Close(); MessageBox.Show("hello welcome"); }
Invalid column name 'username' but username column us there in my database whats the real problem in this coding
INSERT INTO Table2 (username) VALUES (@username)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)