sql - Error In updating Ms-Access Table from C# Code -


i trying update access table c# form. when run program runs without message when click on update breaks , gives following error message:

input string not in correct format.

access table fields:- id(string), name(string), score(int)

error message :-

 public form1()  {     initializecomponent();  }   oledbconnection conn = new oledbconnection(@"provider=microsoft.ace.oledb.12.0;data source=d:\database3.accdb");   public void updaterecord()  {         int score = convert.toint32(textbox2.text);         **string command = "update score set name= '"+textbox1.text+"' , score= '"+score+"' id= '"+textbox3.text+"'  ";**     oledbcommand cmd = new oledbcommand(command,conn);     conn.open();      cmd.executenonquery();  public void showdata() {    string command = "select * score";    oledbcommand cmd = new oledbcommand(command, conn);     oledbdataadapter da = new oledbdataadapter(cmd);    datatable table = new datatable();    da.fill(table);    datagridview1.datasource = table; } 

score integer. have quotes around in string, invalid. try:

string id = textbox3.text; string command = "update score set name= '"+textbox1.text+"' , score= "+textbox2.text+" id= '"+id+"'  "; 

i'd concerned have no data validation in place. if don't enter number in text box? , why converting 'id' integer when it's string field?


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -