c# 4.0 - Error in insert the value into database in asp.net ,c# of registration form -


code show follow:

nection cnn = new sqlconnection("data source=user-pc\\khemchand;integrated security=true");  protected void page_load(object sender, eventargs e) {     cnn.open(); }  protected void button1_click(object sender, eventargs e) {       sqlcommand cmd = new sqlcommand("insert tbl_ragistration values(@f_name,@l_name,@email_id,@pass_word,@[date of brth],@add_ress,@gender)", cnn);     cmd.parameters.addwithvalue("@f_name", texfname.text);     cmd.parameters.addwithvalue("@l_name", texlname.text);     cmd.parameters.addwithvalue("@email_id", texemail.text);     cmd.parameters.addwithvalue("@pass_word", texpwd.text);     cmd.parameters.addwithvalue("@[date o birth]", texdbt.text);     cmd.parameters.addwithvalue("@add_ress", texadd.text);     cmd.parameters.addwithvalue("@gender", dropdownlist1.text);     cmd.executenonquery();     cnn.close(); } 

change cmd.parameters.addwithvalue("@[date o birth]", texdbt.text); cmd.parameters.addwithvalue("@[date of birth]", texdbt.text); in insert parameters value assigning. , dont open connection in page load event. befor executing query open connection, execute query , close connection better approach

       cnn.open();        cmd.executenonquery();        cnn.close();  

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -