Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a record to access 1

Status
Not open for further replies.

MoaD

Programmer
Apr 17, 2002
17
CA
When a user wants to download something from my page i want them to enter an email address and store it in an access database. the code below is what i have right now but the SQL statement isn't working. Any help would be great


Table name = tblEmail
Field = txtEmail


<%
emailAdd = Request.Form(&quot;email&quot;)
SQL = &quot;insert into tblEmail (txtEmail) values (emailAdd)&quot;
dbName = &quot;dsDb&quot;

Set dbCon = Server.CreateObject(&quot;ADODB.Connection&quot;)
dbCon.Open dbName
dbCon.Execute SQL
%>

I've tested each line and they all work up to the Execute line.
 
Try this,

SQL = &quot;insert into tblEmail (txtEmail) values ('&quot; & emailAdd & &quot;');&quot;

Rick
 
Thanks alot Rick your the best
 
Just for future reference, the best way to test those things, is to have it write out the SQL statment to the browser so you can see it. Then you can copy and paste it into the DB to make sure it works.

Example:

Response.write SQL
Response.end

Originally this would have written out

insert into tblEmail (txtEmail) values (emailAdd)

This way you could have seen that it wasn't handling the value correctly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top