When I try to fill textbox1
with a name, I get an exception indicating an invalid column name. When I fill it with a number it works.
The datatype of coach_name
is varchar(50)
.
The insert code is:
// connection setup code
SqlConnection conn = new SqlConnection(connString);
string Coach_Name = textBox1.Text;
try {
string Password1=textBox2.Text;
string Password2=textBox3.Text;
string Password=textBox2.Text;
if (Password1.Equals(Password2))
{
SqlCommand cmd = new SqlCommand("insert into CoachLogins values (" + Coach_Name + ",'" + Password + "')", conn);
conn.Open();
cmd.ExecuteNonQuery(); // hyi insert update delete ma btekhod shi
}