Asp.net Insert Into query local database (acess) -


i not @ running sql queries local database - microsoft access. trying write code when user register details, insert database. have wrote following code it's not working. think have missed out something. appreciated.

 public void insertuserdetails(string fname, string sname, string uid, string password, string email) {     //connection string datbase     string database = "provider=microsoft.ace.oledb.12.0;data source=|datadirectory|/forum.accdb;persist security info=true";     oledbconnection myconn = new oledbconnection(database);       //execute query     string querystr = "insert users(username, password, firstname, surname, email) values ('" + fname + "','" + sname + "','" + uid + "','" + password + "','" + email + "')";       // create command object      oledbcommand mycommand = new oledbcommand(querystr, myconn);     // open connection      mycommand.connection.open();     mycommand.executenonquery();     mycommand.connection.close();  } 

password reserved word. enclose field name in square brackets avoid confusing db engine.

string querystr = "insert users (username, [password], firstname, surname, email) values ('" + fname + "','" + sname + "','" + uid + "','" + password + "','" + email + "')"; 

Comments

Popular posts from this blog

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

keyboard - Smiles and long press feature in Android -

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