c# - Crashing on insert of data into an access database -


i working in c# , inserting data access database. runs crashes when try insert data, idea why?

public partial class studentinfo : form {     private oledbconnection mycon;      public studentinfo()     {         initializecomponent();         mycon = new oledbconnection(@"provider=microsoft.jet.oledb.4.0;data source=c:\documents , settings\administrator\my documents\visual studio 2008\projects\database program\database program\students.mdb");     }        private void insertbtn_click(object sender, eventargs e)     {         oledbcommand cmd = new oledbcommand();         cmd.commandtype = commandtype.text;         cmd.commandtext = "insert studentinfo(rollno,sname,sfather,sadress) values ('"+ rollnotb.text+"','"+nametb.text+"','"+fathertb.text+"','"+adresstb.text+"')";         cmd.connection=mycon;         mycon.open();         cmd.executenonquery();         mycon.close();     } } 

the problem can inserting fields text values , maybe defined numeric in ms access table (rollno?)

also, used using paremeters in queries:

cmd.commandtext = "insert studentinfo(rollno,sname,sfather,sadress) values (?,?,?,?)"; cmd.parameters.add(new oledbparameter("@rollno", rollnovalue)); //etc. 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -