c# - Cannot insert Phone Number into Database (MS Access File) -


i'm creating database app; ms access database file. happens inserted correctly, not phone numbers. when entering phone number application working throws me exception.

i've double checked coding , database , can't figure out why issue caused. here's part of code.

    private void btn_save_click(object sender, eventargs e)     {         {             try             {                 oledbcommand dbcmd = new oledbcommand();                 dbcmd.commandtype = commandtype.text;                 dbcmd.commandtext = "insert tbl_clientinfo (firstname, lastname, address, zipcode, city, state, country, language, phonenr, mobilenr)" + "values (@firstname, @lastname, @address, @zipcode, @city, @state, @country, @language, @phonenr, @mobilenr)";                 dbcmd.parameters.addwithvalue("@firstname", txt_firstname.text);                 dbcmd.parameters.addwithvalue("@lastname", txt_lastname.text);                 dbcmd.parameters.addwithvalue("@address", txt_address.text);                 dbcmd.parameters.addwithvalue("@zipcode", txt_zipcode.text);                 dbcmd.parameters.addwithvalue("@city", txt_city.text);                 dbcmd.parameters.addwithvalue("@state", txt_state.text);                 dbcmd.parameters.addwithvalue("@country", combobox_countries.selecteditem);                 dbcmd.parameters.addwithvalue("@language", combobox_languages.selecteditem);                 dbcmd.parameters.addwithvalue("@phonenr", txt_phonenr.text);                 dbcmd.parameters.addwithvalue("@mobilenr", txt_mobilenr.text);                   dbcmd.connection = dbconnection;                 dbconnection.open();                  dbcmd.executenonquery();                  dbconnection.close();              catch (exception ex)             {                 system.io.streamwriter file = new system.io.streamwriter(@"d:\test.txt");                 file.writeline(ex);                  file.close();             }         }     } 

thanks in advance

language reserved keyword in ms-access jet. need encapsulate in square brackets

dbcmd.commandtext = "insert tbl_clientinfo (firstname, lastname, address, zipcode, " +                      "city, state, country, [language], phonenr, mobilenr)" +                      "values (@firstname, @lastname, @address, @zipcode, " +                      "@city, @state, @country, @language, @phonenr, @mobilenr)"; 

if still possible, suggest change column name. find in predicament every time use table.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -