while insering a record it showing error [Resolved]

Posted by reddysankark-13471 under ASP.NET on 2/29/2012 | Points: 10 | Views : 907 | Status : [Member] | Replies : 1
coding in cs file

protected void Submit_Click(object sender, EventArgs e)
{


SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["sampleConnectionString2"].ToString();
SqlCommand cmd = new SqlCommand("update register set password='" + NPwd.Text+ "' where username = '" + UserId.Text + "' and password='" + Pwd.Text + "'");
try
{
con.Open();
cmd.ExecuteNonQuery();
Response.Write("<script language=Javascript>alert('Your Password Has Been Changed,Please Login With New Password')</script>");
Response.Redirect("~/Default.aspx");
}
catch (System.Data.SqlClient.SqlException exmsg)
{
string msg = "error occur while inserting";
msg += exmsg.Message;
throw new Exception(msg);
}
finally
{
con.Close();
}

it showing an error in executenonquery

sankarreddy


Responses

Posted by: Blessyjees on: 2/29/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi,

Can you specify the exact error message.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response