Trying to get ASP form to show up in Access Database | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| |
Hello, I am new to this forum but have read several posts and I thank you for your great assistance. I am stumped right now. I have a user registration form in asp that is set to a form method=registration.asp page. i will post my registration.asp page below.
I am hoping this asp page will connect to my access database called registration.mdb with a table called registration. however, everytime i submit my registration information, I get an error page that says there is a programming error. I have the SAMS teach yourself ASP 3.0 book and have followed this but am having no luck. Does anyone know why this isn't working. The current page I have listed below is trying to use the dsn-less connection. I also tried the dsn connection but failed there too. Any help would be greatly appreciated. Thanks in advance - Jerry
__________________________________________________ _____________ - <%@ Language=VBScript %>
-
<% Option Explicit %>
-
<!--#include virtual="/adovbs.inc"-->
-
<html>
-
<body>
-
<%
-
Dim objConn
-
Set objConn = Server.CreateObject("ADODB.Connection")
-
objConn.ConnectionString="Driver={Microsoft Access Driver (*.mdb)};" & _
-
"DBQ=C:\Documents and Settings\MM\Desktop\Website\registration.mdb"
-
objConn.Open
-
-
Dim objRS, bolAlreadyExists
-
If ((Request.Form("firstname") = "") OR (Request.Form("lastname") = "") _
-
OR (Request.Form("street") = "") OR (Request.Form("city") = "") _
-
OR (Request.Form("state") = "") OR (Request.Form("zipcode") = "") _
-
OR (Request.Form("birthdate") = "") oR (Request.Form("email") = "") _
-
OR (Request.Form("confirmemail") = "") oR (Request.Form("password") = "") _
-
OR (Request.Form("confirmpassword") = "") oR (Request.Form("question") = "") _
-
OR (Request.Form("answer") = "") oR (Request.Form("confirmanswer") = "") _
-
OR (Request.Form("interest") = "") oR (Request.Form("nonewsemail") = "") _
-
OR (Request.Form("hearabout") = "")
-
-
Response.Write "<a href='registration.html'>"
-
Response.Write "You must enter values for all the fields."
-
Response.Write "</a>"
-
Else
-
bolAlreadyExists = False
-
Set objRS = Server.CreateObject("ADODB.Recordset")
-
objRS.Open "registration", objConn, , adLockOptimistic, adCmdTable
-
Do While Not (objRS.EOF OR bolAlreadyExists)
-
If (StrComp(objRS("email"), Request.Form("email"), _
-
vbTextCompare) = 0) Then
-
Response.Write "<a href='registration.html'>"
-
Response.Write "Email address already found in table."
-
Response.Write "</a>
-
bolAlreadyExists = True
-
End If
-
objRS.MoveNext
-
Loop
-
If Not bolAlreadyExists Then
-
-
objRS.AddNew
-
-
objRS("firstname") = Request.Form("firstname")
-
objRS("lastname") = Request.Form("lastname")
-
objRS("street") = Request.Form("street")
-
objRS("city") = Request.Form("city")
-
objRS("state") = Request.Form("state")
-
objRS("zipcode") = Request.Form("zipcode")
-
objRS("birthdate") = Request.Form("birthdate")
-
objRS("email") = Request.Form("email")
-
objRS("confirmemail") = Request.Form("confirmemail")
-
objRS("password") = Request.Form("password")
-
objRS("confirmpassword") = Request.Form("confirmpassword")
-
objRS("question") = Request.Form("question")
-
objRS("answer") = Request.Form("answer")
-
objRS("confirmanswer") = Request.Form("confirmanswer")
-
objRS("awardprogram") = Request.Form("awardprogram")
-
objRS("accountnumber") = Request.Form("accountnumber")
-
objRS("interest") = Request.Form("interest")
-
objRS("nonewsemail") = Request.Form("nonewsemail")
-
objRS("hearabout") = Request.Form("hearabout")
-
objRS.Update
-
Response.Write "Thank you for registering."
-
End If
-
objRS.Close
-
Set objRS = Nothing
-
End If
-
objConn.Close
-
Set objConn = Nothing
-
%>
-
</body>
-
</html>
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
one other question to go with my previous post. i am currently trying to use html/asp/microsoft access. would it be easier to use php/mysql? i have a hosting account at godaddy and they allow both i believe. i have read that php/mysql is easier but i have set everything up in asp/access thus far. just curious because i am new to web design but very facinated by it. my webpage is pretty basic. just a page for users to register, then check their points earned balances and edit their registration info if necessary. if i can figure out how to get their user info into a database, i feel i am almost there.
any guidance to the correct scripting languages would be very beneficial.
thanks in advance - Jerry
|  | Moderator | | Join Date: Jan 2008 Location: Winchester, UK
Posts: 930
| | | re: Trying to get ASP form to show up in Access Database
Hi Jerry,
Firstly, welcome to Bytes.com! I hope you find the site useful.
Secondly, please don't forget to wrap your code in CODE tags - it makes your posts much easier to read - and please read the Posting Guidelines if you have not done so already.
Could you print the error that you are getting on your page please. Make sure that you have Friendly HTTP Error Messages turned off in your browser options so you can see the actual error that is being returned.
Thanks,
Dr B
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
Thank you for your quick response Dr. B. Below is the error message I am getting. My connection to the internet is fine so I am not sure what is going on. Any ideas?
__________________________________________________ ____________
Internet Explorer cannot display the webpage
Most likely causes:
You are not connected to the Internet.
The website is encountering problems.
There might be a typing error in the address.
What you can try:
Diagnose Connection Problems
More information
This problem can be caused by a variety of issues, including:
Internet connectivity has been lost.
The website is temporarily unavailable.
The Domain Name Server (DNS) is not reachable.
The Domain Name Server (DNS) does not have a listing for the website's domain.
If this is an HTTPS (secure) address, click Tools, click Internet Options, click Advanced, and check to be sure the SSL and TLS protocols are enabled under the security section.
For offline users
You can still view subscribed feeds and some recently viewed webpages.
To view subscribed feeds
Click the Favorites Center button , click Feeds, and then click the feed you want to view.
To view recently visited webpages (might not work on all pages)
Click Tools , and then click Work Offline.
Click the Favorites Center button , click History, and then click the page you want to view.
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
The last post was the error message I received when I tried to submit offline.
When I put my webpages on the ftp client and try to submit, I get the following error message.
__________________________________________________ ________
Microsoft VBScript compilation error '800a03ee'
Expected ')'
/registration.asp, line 22
OR (Request.Form("hearabout") = "")
-----------------------------------^
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
sorry for multiple posts but I went into my registration.asp page and deleted the
"hearabout" line that caused the problem last time and got the following error message. I really appreciate your help. Thanks again.
__________________________________________________ ______
Microsoft VBScript compilation error '800a03ee'
Expected ')'
/registration.asp, line 24
Response.Write "<a href='registration.html'>"
^
|  | Moderator | | Join Date: Jan 2008 Location: Winchester, UK
Posts: 930
| | | re: Trying to get ASP form to show up in Access Database
The error is obviously that you have a missing parenthesis somewhere but the question is where. Can you print a bit more of the code that comes before this line so I can see what is going on please.
Thanks,
Dr B
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
i am not sure what code you would like me to post but here is the registration.asp page I have been using. If you would like me to post anything else, please let me know. - <%@ Language=VBScript %>
-
<% Option Explicit %>
-
<!--#include virtual="/adovbs.inc"-->
-
<html>
-
<body>
-
<%
-
Dim objConn
-
Set objConn = Server.CreateObject("ADODB.Connection")
-
objConn.ConnectionString="Driver={Microsoft Access Driver (*.mdb)};" & _
-
"DBQ=C:\Documents and Settings\MM\Desktop\Website\registration.mdb"
-
objConn.Open
-
-
Dim objRS, bolAlreadyExists
-
If ((Request.Form("firstname") = "") OR (Request.Form("lastname") = "") _
-
OR (Request.Form("street") = "") OR (Request.Form("city") = "") _
-
OR (Request.Form("state") = "") OR (Request.Form("zipcode") = "") _
-
OR (Request.Form("birthdate") = "") oR (Request.Form("email") = "") _
-
OR (Request.Form("confirmemail") = "") oR (Request.Form("password") = "") _
-
OR (Request.Form("confirmpassword") = "") oR (Request.Form("question") = "") _
-
OR (Request.Form("answer") = "") oR (Request.Form("confirmanswer") = "") _
-
OR (Request.Form("interest") = "") oR (Request.Form("nonewsemail") = "") _
-
-
-
Response.Write "<a href='registration.html'>"
-
Response.Write "You must enter values for all the fields."
-
Response.Write "</a>"
-
Else
-
bolAlreadyExists = False
-
Set objRS = Server.CreateObject("ADODB.Recordset")
-
objRS.Open "registration", objConn, , adLockOptimistic, adCmdTable
-
Do While Not (objRS.EOF OR bolAlreadyExists)
-
If (StrComp(objRS("email"), Request.Form("email"), _
-
vbTextCompare) = 0) Then
-
Response.Write "<a href='registration.html'>"
-
Response.Write "Email address already found in table."
-
Response.Write "</a>
-
bolAlreadyExists = True
-
End If
-
objRS.MoveNext
-
Loop
-
If Not bolAlreadyExists Then
-
-
objRS.AddNew
-
-
objRS("firstname") = Request.Form("firstname")
-
objRS("lastname") = Request.Form("lastname")
-
objRS("street") = Request.Form("street")
-
objRS("city") = Request.Form("city")
-
objRS("state") = Request.Form("state")
-
objRS("zipcode") = Request.Form("zipcode")
-
objRS("birthdate") = Request.Form("birthdate")
-
objRS("email") = Request.Form("email")
-
objRS("confirmemail") = Request.Form("confirmemail")
-
objRS("password") = Request.Form("password")
-
objRS("confirmpassword") = Request.Form("confirmpassword")
-
objRS("question") = Request.Form("question")
-
objRS("answer") = Request.Form("answer")
-
objRS("confirmanswer") = Request.Form("confirmanswer")
-
objRS("awardprogram") = Request.Form("awardprogram")
-
objRS("accountnumber") = Request.Form("accountnumber")
-
objRS("interest") = Request.Form("interest")
-
objRS("nonewsemail") = Request.Form("nonewsemail")
-
objRS("hearabout") = Request.Form("hearabout")
-
objRS.Update
-
Response.Write "Thank you for registering."
-
End If
-
objRS.Close
-
Set objRS = Nothing
-
End If
-
objConn.Close
-
Set objConn = Nothing
-
%>
-
</body>
-
</html>
|  | Expert | | Join Date: Oct 2008 Location: Bristol, United Kingdom
Posts: 145
| | | re: Trying to get ASP form to show up in Access Database
Hiya,
I think your problem is that you open a parenthesis here: - If ((Request.Form("firstname") = "") OR (Request.Form("lastname")
But I can't find where it is closed.
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
thank you for your response.
i added a parentheses at the end of this statement after "nonewsemail" - Dim objRS, bolAlreadyExists
-
If ((Request.Form("firstname") = "") OR (Request.Form("lastname") = "") _
-
OR (Request.Form("street") = "") OR (Request.Form("city") = "") _
-
OR (Request.Form("state") = "") OR (Request.Form("zipcode") = "") _
-
OR (Request.Form("birthdate") = "") oR (Request.Form("email") = "") _
-
OR (Request.Form("confirmemail") = "") oR (Request.Form("password") = "") _
-
OR (Request.Form("confirmpassword") = "") oR (Request.Form("question") = "") _
-
OR (Request.Form("answer") = "") oR (Request.Form("confirmanswer") = "") _
-
OR (Request.Form("interest") = "") oR (Request.Form("nonewsemail") = "")) Then
-
-
-
Response.Write "<a href='registration.html'>"
-
Response.Write "You must enter values for all the fields."
-
Response.Write "</a>"
after i made the above change, i got the following error code.
__________________________________________________
Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/registration.asp, line 36
Response.Write "</a>
--------------------^
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
hello again, I have been messing around with the error code I received as shown in the post above.
If I add an additional " to my registration.asp code like this "</a>"", I receive the following error
****Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/registration.asp, line 36
Response.Write "</a>""
It seems that if I put more quotations around this they show up in the error code but if I only have "</a>" then the error code looks like this....
****Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/registration.asp, line 36
Response.Write "</a>
I am not sure why it is not reading the last quotation even though I have
"</a>" in my code.
any ideas?
|  | Expert | | Join Date: Oct 2008 Location: Bristol, United Kingdom
Posts: 145
| | | re: Trying to get ASP form to show up in Access Database Quote:
Originally Posted by jerrydigital hello again, I have been messing around with the error code I received as shown in the post above.
If I add an additional " to my registration.asp code like this "</a>"", I receive the following error
****Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/registration.asp, line 36
Response.Write "</a>""
It seems that if I put more quotations around this they show up in the error code but if I only have "</a>" then the error code looks like this....
****Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/registration.asp, line 36
Response.Write "</a>
I am not sure why it is not reading the last quotation even though I have
"</a>" in my code.
any ideas? On the code you posted in post #8, line 36 did contain an unterminated string:
Can you post the updated code in its entirety?
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
thank you for your insight. i was looking at the wrong </a> section before, good catch. So, I corrected that and now I am having trouble with the connection to the access database. I set up a dsn connection called registration.dsn. I did this by going to the control panel/admin tools/data sources(ODBC)...Then I clicked the System DSN tab and added a connection(Microsoft Access Driver *.mdb), and i named this registration.dsn. I get the following error code
___
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/registration.asp, line 10
____
here is my updated code. i have a hosting account with godaddy, would this cause the problem? - <%@ Language=VBScript %>
-
<% Option Explicit %>
-
<!--#include virtual="/adovbs.inc"-->
-
<html>
-
<body>
-
<%
-
Dim objConn
-
Set objConn = Server.CreateObject("ADODB.Connection")
-
objConn.ConnectionString = "DSN=registration.dsn"
-
objConn.Open
-
Dim objRS, bolAlreadyExists
-
If ((Request.Form("firstname") = "") OR (Request.Form("lastname") = "") _
-
OR (Request.Form("street") = "") OR (Request.Form("city") = "") _
-
OR (Request.Form("state") = "") OR (Request.Form("zipcode") = "") _
-
OR (Request.Form("birthdate") = "") OR (Request.Form("email") = "") _
-
OR (Request.Form("confirmemail") = "") OR (Request.Form("password") = "") _
-
OR (Request.Form("confirmpassword") = "") OR (Request.Form("question") = "") _
-
OR (Request.Form("answer") = "") OR (Request.Form("confirmanswer") = "") _
-
OR (Request.Form("interest") = "") OR (Request.Form("nonewsemail") = "")) Then
-
-
-
Response.Write "<a href='registration.html'>"
-
Response.Write "You must enter values for all the fields."
-
Response.Write "</a>"
-
Else
-
bolAlreadyExists = False
-
Set objRS = Server.CreateObject("ADODB.Recordset")
-
objRS.Open "registration", objConn, , adLockOptimistic, adCmdTable
-
Do While Not (objRS.EOF OR bolAlreadyExists)
-
If (StrComp(objRS("email"), Request.Form("email"), _
-
vbTextCompare) = 0) Then
-
Response.Write "<a href='registration.html'>"
-
Response.Write "Email address already found in table."
-
Response.Write "</a>"
-
bolAlreadyExists = True
-
End If
-
objRS.MoveNext
-
Loop
-
If Not bolAlreadyExists Then
-
-
objRS.AddNew
-
-
objRS("firstname") = Request.Form("firstname")
-
objRS("lastname") = Request.Form("lastname")
-
objRS("street") = Request.Form("street")
-
objRS("city") = Request.Form("city")
-
objRS("state") = Request.Form("state")
-
objRS("zipcode") = Request.Form("zipcode")
-
objRS("birthdate") = Request.Form("birthdate")
-
objRS("email") = Request.Form("email")
-
objRS("confirmemail") = Request.Form("confirmemail")
-
objRS("password") = Request.Form("password")
-
objRS("confirmpassword") = Request.Form("confirmpassword")
-
objRS("question") = Request.Form("question")
-
objRS("answer") = Request.Form("answer")
-
objRS("confirmanswer") = Request.Form("confirmanswer")
-
objRS("awardprogram") = Request.Form("awardprogram")
-
objRS("accountnumber") = Request.Form("accountnumber")
-
objRS("interest") = Request.Form("interest")
-
objRS("nonewsemail") = Request.Form("nonewsemail")
-
objRS("hearabout") = Request.Form("hearabout")
-
objRS.Update
-
Response.Write "Thank you for registering."
-
End If
-
objRS.Close
-
Set objRS = Nothing
-
End If
-
objConn.Close
-
Set objConn = Nothing
-
%>
-
</body>
-
</html>
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: Trying to get ASP form to show up in Access Database
try: -
objConn.ConnectionString = "DSN=registration"
-
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
Hi, thanks for you thoughts. However, using "DSN=registration" and dropping the .dsn gave me the same error code as before
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/registration.asp, line 10
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: Trying to get ASP form to show up in Access Database
What kind of database are you using? and did you actually make the DSN?
Jared
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
hello, I am using a Microsoft Access database called registration.mdb with a table called registration.
I created the DSN by going to Start/Control Panel/Administrative Tools/Data Bases(ODBC)....then I clicked on the System DSN tab and added Microsoft Access Driver (*.mdb) and named it registration.dsn.
It shows up when i open up the Data Bases(ODBC) folder under the System DSN tab.
Not sure if this is the correct method, I am following steps from SAMS Teach Yourself ASP 3.0.
I tried to contact Godaddy.com where I have my hosting account through but they constantly tell me they are not allowed to assist with scripting so I am at a stand still.
However, godaddy.com does have a help section that has the following instructions describing using ASP/ADO to connect to an Access Database. How would I implement these instructions into my code listed above? - <%
-
Dim oConn, oRs
-
Dim qry, connectstr
-
Dim db_path
-
Dim db_dir
-
db_dir = Server.MapPath("access_db") & "\"
-
db_path = db_dir & "yourdatabasefile.mdb"
-
fieldname = "your_field"
-
tablename = "your_table"
-
-
connectstr = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & db_path
-
-
Set oConn = Server.CreateObject("ADODB.Connection")
-
oConn.Open connectstr
-
qry = "SELECT * FROM " & tablename
-
-
Set oRS = oConn.Execute(qry)
-
-
if not oRS.EOF then
-
while not oRS.EOF
-
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
-
"
-
oRS.movenext
-
wend
-
oRS.close
-
end if
-
-
Set oRs = nothing
-
Set oConn = nothing
-
-
%>
|  | Expert | | Join Date: Oct 2008 Location: Bristol, United Kingdom
Posts: 145
| | | re: Trying to get ASP form to show up in Access Database Quote:
Originally Posted by jerrydigital hello, I am using a Microsoft Access database called registration.mdb with a table called registration.
I created the DSN by going to Start/Control Panel/Administrative Tools/Data Bases(ODBC)....then I clicked on the System DSN tab and added Microsoft Access Driver (*.mdb) and named it registration.dsn.
It shows up when i open up the Data Bases(ODBC) folder under the System DSN tab.
Not sure if this is the correct method, I am following steps from SAMS Teach Yourself ASP 3.0.
I tried to contact Godaddy.com where I have my hosting account through but they constantly tell me they are not allowed to assist with scripting so I am at a stand still.
However, godaddy.com does have a help section that has the following instructions describing using ASP/ADO to connect to an Access Database. How would I implement these instructions into my code listed above? - <%
-
Dim oConn, oRs
-
Dim qry, connectstr
-
Dim db_path
-
Dim db_dir
-
db_dir = Server.MapPath("access_db") & "\"
-
db_path = db_dir & "yourdatabasefile.mdb"
-
fieldname = "your_field"
-
tablename = "your_table"
-
-
connectstr = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & db_path
-
-
Set oConn = Server.CreateObject("ADODB.Connection")
-
oConn.Open connectstr
-
qry = "SELECT * FROM " & tablename
-
-
Set oRS = oConn.Execute(qry)
-
-
if not oRS.EOF then
-
while not oRS.EOF
-
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
-
"
-
oRS.movenext
-
wend
-
oRS.close
-
end if
-
-
Set oRs = nothing
-
Set oConn = nothing
-
-
%>
I am starting to think your domain is hosted in shared webspace (on linux using SunOne ASP probably) and not on a dedicated Windows Server.
So can I ask on what machine you created the DSN? Was it your local PC or am I wrong, and you do have a dedicated Windows server and that is where you set it up?
Also the above Go Daddy code is illustrating a DSN-less connection to a database you specify stored in directory called "access_db" within the webspace, which then prints out the contents of the field you specify from the table you specify.
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
I am not sure exactly if I am answering your question correctly, but I will try my best.
I set up the DSN connection on my personal dell laptop.
I have a hosting account with godaddy.com and I have to upload my webpages(html, asp, mdb) to the FTP client they issued...I am not sure if this is a dedicated or shared site.
Do you think this is why it can't read my dsn connection? if so, is it possible to do what i am trying or do i have to use the godaddy tools? The problem is, when I contact them to ask questions, they simply state they are not allowed to help with 3rd party scripting.
Thank you for clearing up the godaddy code i posted. sounds like that code would assist me if i created a table on their website.
if you know of any way to set up a connection using my database i have created on godaddy.com's hosting account, please let me know
thanks so much for all of your help so far, it is much appreciated.
|  | Expert | | Join Date: Oct 2008 Location: Bristol, United Kingdom
Posts: 145
| | | re: Trying to get ASP form to show up in Access Database Quote:
Originally Posted by jerrydigital I am not sure exactly if I am answering your question correctly, but I will try my best.
I set up the DSN connection on my personal dell laptop.
I have a hosting account with godaddy.com and I have to upload my webpages(html, asp, mdb) to the FTP client they issued...I am not sure if this is a dedicated or shared site.
Do you think this is why it can't read my dsn connection? if so, is it possible to do what i am trying or do i have to use the godaddy tools? The problem is, when I contact them to ask questions, they simply state they are not allowed to help with 3rd party scripting.
Thank you for clearing up the godaddy code i posted. sounds like that code would assist me if i created a table on their website.
if you know of any way to set up a connection using my database i have created on godaddy.com's hosting account, please let me know
thanks so much for all of your help so far, it is much appreciated. Yes the connection is failing because it can't see the DSN on your computer, and nor would you want it to.
You need to upload your access db into your webspace and create a DSN-less connection to it there.
I recommend that you do use Go Daddy's example code just to test the connection. When you know it works, then apply its principles to your page.
Just remember to change the MapPath, "yourfield", "yourtable" and yourdatabase" stuff to your actual database details. Or better yet use a very simple SQL statement so there's even less margin for error, something like: - SELECT field FROM table WHERE ID = 1
Then just write out that one value with: | | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
ok, thanks. i will work on this tonight and let you know how it works out.
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
I looked on godaddy and they have a place to set up a DSN. I named my access_register.dsn.
I also found the following code to use to connect to the dsn - <%
-
Dim oConn, oRs
-
Dim qry, connectstr, sDSNDir
-
Dim db_name, db_username, db_userpassword
-
Dim dsn_name
-
-
dsn_name = "your_dsn_name"
-
fieldname = "your_fieldname"
-
tablename = "your_tablename"
-
-
'assumes that _dsn exists in the root
-
sDSNDir = Server.MapPath("/_dsn")
-
-
connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
-
-
Set oConn = Server.CreateObject("ADODB.Connection")
-
oConn.Open connectstr
-
qry = "SELECT * FROM " & tablename
-
-
Set oRS = oConn.Execute(qry)
-
-
if not oRS.EOF then
-
while not oRS.EOF
-
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & " "
-
oRS.movenext
-
wend
-
oRS.close
-
end if
-
-
Set oRs = nothing
-
Set oConn = nothing
-
-
%>
I am going to continue to play with this but what can I eliminate from the above godaddy code if all I am trying to do is have the user register and have their information store into the database table I created in Access called registration? Do I just need to add in my code? Sorry for all the questions, I am so new to this but feel like i am very close to accomplishing this step.
Below is my current asp page code. - <%@ Language=VBScript %>
-
<% Option Explicit %>
-
<!--#include virtual="/adovbs.inc"-->
-
<html>
-
<body>
-
<%
-
Dim objConn
-
Set objConn = Server.CreateObject("ADODB.Connection")
-
objConn.ConnectionString = "DSN=access_register.dsn"
-
objConn.Open
-
Dim objRS, bolAlreadyExists
-
If ((Request.Form("firstname") = "") OR (Request.Form("lastname") = "") _
-
OR (Request.Form("street") = "") OR (Request.Form("city") = "") _
-
OR (Request.Form("state") = "") OR (Request.Form("zipcode") = "") _
-
OR (Request.Form("birthdate") = "") OR (Request.Form("email") = "") _
-
OR (Request.Form("confirmemail") = "") OR (Request.Form("password") = "") _
-
OR (Request.Form("confirmpassword") = "") OR (Request.Form("question") = "") _
-
OR (Request.Form("answer") = "") OR (Request.Form("confirmanswer") = "") _
-
OR (Request.Form("interest") = "") OR (Request.Form("nonewsemail") = "")) Then
-
-
-
Response.Write "<a href='registration.html'>"
-
Response.Write "You must enter values for all the fields."
-
Response.Write "</a>"
-
Else
-
bolAlreadyExists = False
-
Set objRS = Server.CreateObject("ADODB.Recordset")
-
objRS.Open "registration", objConn, , adLockOptimistic, adCmdTable
-
Do While Not (objRS.EOF OR bolAlreadyExists)
-
If (StrComp(objRS("email"), Request.Form("email"), _
-
vbTextCompare) = 0) Then
-
Response.Write "<a href='registration.html'>"
-
Response.Write "Email address already found in table."
-
Response.Write "</a>"
-
bolAlreadyExists = True
-
End If
-
objRS.MoveNext
-
Loop
-
If Not bolAlreadyExists Then
-
-
objRS.AddNew
-
-
objRS("firstname") = Request.Form("firstname")
-
objRS("lastname") = Request.Form("lastname")
-
objRS("street") = Request.Form("street")
-
objRS("city") = Request.Form("city")
-
objRS("state") = Request.Form("state")
-
objRS("zipcode") = Request.Form("zipcode")
-
objRS("birthdate") = Request.Form("birthdate")
-
objRS("email") = Request.Form("email")
-
objRS("confirmemail") = Request.Form("confirmemail")
-
objRS("password") = Request.Form("password")
-
objRS("confirmpassword") = Request.Form("confirmpassword")
-
objRS("question") = Request.Form("question")
-
objRS("answer") = Request.Form("answer")
-
objRS("confirmanswer") = Request.Form("confirmanswer")
-
objRS("awardprogram") = Request.Form("awardprogram")
-
objRS("accountnumber") = Request.Form("accountnumber")
-
objRS("interest") = Request.Form("interest")
-
objRS("nonewsemail") = Request.Form("nonewsemail")
-
objRS("hearabout") = Request.Form("hearabout")
-
objRS.Update
-
Response.Write "Thank you for registering."
-
End If
-
objRS.Close
-
Set objRS = Nothing
-
End If
-
objConn.Close
-
Set objConn = Nothing
-
%>
-
</body>
-
</html>
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
ok, i tried to implement the godaddy code to connect to their shared server but i am coming across the following error
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x4500 Thread 0x4b9c DBC 0xa80d39c Jet'.
/registration2.asp, line 22
I know I have made some errors but I don't know where to begin to fix this error code. Here is my current asp processing page - <%@ Language=VBScript %>
-
<% Option Explicit %>
-
<!--#include virtual="/adovbs.inc"-->
-
<html>
-
<body>
-
<%
-
Dim oConn, oRs
-
Dim connectstr, sDSNDir
-
Dim db_name, db_username, db_userpassword
-
Dim dsn_name, tablename
-
-
dsn_name = "access_register.dsn"
-
tablename = "registration"
-
-
sDSNDir = Server.MapPath("/_dsn")
-
-
connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
-
-
Set oConn = Server.CreateObject("ADODB.Connection")
-
oConn.Open connectstr
-
-
Dim objRS, bolAlreadyExists
-
If ((Request.Form("firstname") = "") OR (Request.Form("lastname") = "") _
-
OR (Request.Form("street") = "") OR (Request.Form("city") = "") _
-
OR (Request.Form("state") = "") OR (Request.Form("zipcode") = "") _
-
OR (Request.Form("birthdate") = "") OR (Request.Form("email") = "") _
-
OR (Request.Form("confirmemail") = "") OR (Request.Form("password") = "") _
-
OR (Request.Form("confirmpassword") = "") OR (Request.Form("question") = "") _
-
OR (Request.Form("answer") = "") OR (Request.Form("confirmanswer") = "") _
-
OR (Request.Form("interest") = "") OR (Request.Form("nonewsemail") = "")) Then
-
-
-
Response.Write "<a href='registration.html'>"
-
Response.Write "You must enter values for all the fields."
-
Response.Write "</a>"
-
Else
-
bolAlreadyExists = False
-
Set objRS = Server.CreateObject("ADODB.Recordset")
-
objRS.Open "registration", objConn, , adLockOptimistic, adCmdTable
-
Do While Not (objRS.EOF OR bolAlreadyExists)
-
If (StrComp(objRS("email"), Request.Form("email"), _
-
vbTextCompare) = 0) Then
-
Response.Write "<a href='registration.html'>"
-
Response.Write "Email address already found in table."
-
Response.Write "</a>"
-
bolAlreadyExists = True
-
End If
-
objRS.MoveNext
-
Loop
-
If Not bolAlreadyExists Then
-
-
objRS.AddNew
-
-
objRS("firstname") = Request.Form("firstname")
-
objRS("lastname") = Request.Form("lastname")
-
objRS("street") = Request.Form("street")
-
objRS("city") = Request.Form("city")
-
objRS("state") = Request.Form("state")
-
objRS("zipcode") = Request.Form("zipcode")
-
objRS("birthdate") = Request.Form("birthdate")
-
objRS("email") = Request.Form("email")
-
objRS("confirmemail") = Request.Form("confirmemail")
-
objRS("password") = Request.Form("password")
-
objRS("confirmpassword") = Request.Form("confirmpassword")
-
objRS("question") = Request.Form("question")
-
objRS("answer") = Request.Form("answer")
-
objRS("confirmanswer") = Request.Form("confirmanswer")
-
objRS("awardprogram") = Request.Form("awardprogram")
-
objRS("accountnumber") = Request.Form("accountnumber")
-
objRS("interest") = Request.Form("interest")
-
objRS("nonewsemail") = Request.Form("nonewsemail")
-
objRS("hearabout") = Request.Form("hearabout")
-
objRS.Update
-
Response.Write "Thank you for registering."
-
End If
-
objRS.Close
-
Set objRS = Nothing
-
End If
-
objConn.Close
-
Set objConn = Nothing
-
%>
-
</body>
-
</html>
|  | Expert | | Join Date: Oct 2008 Location: Bristol, United Kingdom
Posts: 145
| | | re: Trying to get ASP form to show up in Access Database This Page suggests that the problem is with file permissions. I suggest you look there.
I still also believe you should attempt to connect using a very basic page and, once that works, apply the same principles to your registration page.
| | Member | | Join Date: Oct 2008 Location: Cleveland Ohio
Posts: 67
| | | re: Trying to get ASP form to show up in Access Database
thank you so much for all of your help.
i followed your recommendation and cut down my form code. then i kept plugging away at the godaddy.com code they provided and eventually, I got my registration form submit info to show up in the access table.
so, my question has been answered and i am moving on to the next step. thank you all again, I really appreciate the help. this website is a true blessing. have a nice weekend, and i am sure i will be asking questions down the road.....
Jerry
|  | Similar ASP / Active Server Pages bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|