string sql = "Update stdrecord set firstname='" + fname + "',lastname='" + lname + "',mobile='" + mob + "',phone='" + phn + "',city='" + city + "',province='" + prov + "'where id='" + id + "'";
You miss =
after province and there is no space between prov and where
!
Also in this case you are open to SqlInjection, please use SqlCommand.Parameters.
The Query should look like this.
string sql = @"Update stdrecord set firstname=@FName ,lastname=@LastName, mobile=@Mobile,
phone=@Phone,city=@City, province=@Province where id=@ID";
This will protect you from SqlInjection and also sql server will cache your query.
To using command Parameters you need to add this code to your SqlCommand
SqlCommand cmd = new SqlCommand(sql, connectionString);
cmd.Parameters.AddWithValue("@FName", fName);
cmd.Parameters.AddWithValue("@LastName", lname );
cmd.Parameters.AddWithValue("@Mobile", mob);
cmd.Parameters.AddWithValue("@Phone", phn);
cmd.Parameters.AddWithValue("@City", city);
cmd.Parameters.AddWithValue("@Province", prov);
cmd.Parameters.AddWithValue("@ID", id);
With this structure you will not have problems like this in future because you will not add +
and '
non stop. Also use @
when you build string this give you the possibility to write string on more than one line without using +
.