c# - An exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll but was not handled in user code Additional information: Overflow -
protected void btnsubmitform_click(object sender, eventargs e) { page.validate(); if (page.isvalid) { connparam = @"provider=microsoft.ace.oledb.12.0;data source=" + server.mappath("validation.accdb") + ";persist security info=false;"; oledbconnection con = new oledbconnection(connparam); con.open(); oledbcommand cmd = new oledbcommand("insert tblclients (firstname,lastname, phone,streetaddress,city,country, zipcode) values (@fname,@lname,@phone,@saddress,@city,@country, @zipcode)", con); cmd.parameters.addwithvalue("@fname", fname.text); cmd.parameters.addwithvalue("@lname", lname.text); cmd.parameters.addwithvalue("@phone", phone.text); cmd.parameters.addwithvalue("@saddress", address.text); cmd.parameters.addwithvalue("@city", city.text); cmd.parameters.addwithvalue("@country", country.text); cmd.parameters.addwithvalue("@zipcode", zipcode.text); cmd.executenonquery(); con.close(); response.redirect("display.aspx"); } }
my insert works when press submit button many times (i have validators test whether or not text boxes entered or missing text) 'cmd.executenonquery();' gives exception error. don't know why, i'm new, therefore tips helpful thank you.
Comments
Post a Comment