By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,061 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

I am having trouble entering textbox data into an access database

P: 5
Good morning
i have been struggling to insert data into my access data base via textboxes on a webpage. The error is INSERT INTO syntax error but I am struggeling to pinpoint where the syntax error lies.
this is the code I used

Expand|Select|Wrap|Line Numbers
  1. string connString = @"Provider=Microsoft.Jet.OleDb.4.0; 
  2.                             Data Source=" +  Request.PhysicalApplicationPath + "App_Data\\UserInfo.mdb";
  3.         OleDbConnection conn = new OleDbConnection(connString);
  4.         conn.Open();
  5.  
  6.  
  7.  
  8.         OleDbCommand cmd = conn.CreateCommand();
  9.  
  10.         cmd.CommandText = "INSERT INTO Users (emailAddress, userName, password)VALUES('" + this.txtEmail.Text + "','" + this.txtUsername.Text + "', '" + this.txtPassword.Text + "')";
  11.  
  12.         cmd.ExecuteNonQuery();
  13.         conn.Close();
  14.         //Response.Write(cmd.CommandText);
  15.  
everything seemingly is fine but apparently not.

kind regards
Apr 11 '11 #1
Share this Question
Share on Google+
1 Reply


jhardman
Expert 2.5K+
P: 3,405
You coded that as if you were a javascript user :). The problem is that oncw the form is submitted, you can no longer access the textfiles as part of this.etc. It is now part of the request object. Try this:
Expand|Select|Wrap|Line Numbers
  1. cmd.CommandText = "INSERT INTO Users (emailAddress, userName, password)VALUES('" + request("txtEmail") + "','" + request("txtUsername") + "', '" + request("txtPassword") + "')";
let me know if this helps.

Jared
Jun 22 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.