asp.net cannot update database

Posted by tom on Stack Overflow See other posts from Stack Overflow or by tom
Published on 2010-03-31T21:11:01Z Indexed on 2010/03/31 21:13 UTC
Read the original article Hit count: 332

Filed under:
string ConnectionString = WebConfigurationManager.ConnectionStrings["dbnameConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(ConnectionString);

myConnection.Open();
try
{
    string qry = "UPDATE customers SET firstname=@firstname WHERE cid=1";
    SqlCommand insertQuery = new SqlCommand(qry, myConnection);
    insertQuery.Parameters.Add(new SqlParameter("@firstname", txtFirstname.Text));
    insertQuery.ExecuteNonQuery();

    myConnection.Close();
}
catch (Exception ee)
{

}

Any suggestions?

© Stack Overflow or respective owner

Related posts about ASP.NET