sorry i am a newbie and my friend found out some coding error.
i am not able to understand what the problem is.
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");
}
the error is comming new executenonquery and saying that
Invalid column name 'username' but username column us there in my database whats the real problem in this coding