Trying to get ASP form to show up in Access Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jerrydigital
    New Member
    • Oct 2008
    • 67

    Trying to get ASP form to show up in Access Database

    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=registra tion.asp page. i will post my registration.as p page below.

    I am hoping this asp page will connect to my access database called registration.md b 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
    _______________ _______________ _______________ _______________ ___

    Code:
    <%@ 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>
    Last edited by DrBunchman; Oct 29 '08, 09:58 AM. Reason: Added [Code] Tags - Please use the '#' button
  • jerrydigital
    New Member
    • Oct 2008
    • 67

    #2
    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

    Comment

    • DrBunchman
      Recognized Expert Contributor
      • Jan 2008
      • 979

      #3
      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

      Comment

      • jerrydigital
        New Member
        • Oct 2008
        • 67

        #4
        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.

        Comment

        • jerrydigital
          New Member
          • Oct 2008
          • 67

          #5
          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.as p, line 22

          OR (Request.Form(" hearabout") = "")
          -----------------------------------^

          Comment

          • jerrydigital
            New Member
            • Oct 2008
            • 67

            #6
            sorry for multiple posts but I went into my registration.as p 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.as p, line 24

            Response.Write "<a href='registrat ion.html'>"
            ^

            Comment

            • DrBunchman
              Recognized Expert Contributor
              • Jan 2008
              • 979

              #7
              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

              Comment

              • jerrydigital
                New Member
                • Oct 2008
                • 67

                #8
                i am not sure what code you would like me to post but here is the registration.as p page I have been using. If you would like me to post anything else, please let me know.

                Code:
                <%@ 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>

                Comment

                • GazMathias
                  Recognized Expert New Member
                  • Oct 2008
                  • 228

                  #9
                  Hiya,

                  I think your problem is that you open a parenthesis here:

                  Code:
                  If ((Request.Form("firstname") = "") OR (Request.Form("lastname")
                  But I can't find where it is closed.

                  Comment

                  • jerrydigital
                    New Member
                    • Oct 2008
                    • 67

                    #10
                    thank you for your response.

                    i added a parentheses at the end of this statement after "nonewsemai l"

                    Code:
                    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.as p, line 36

                    Response.Write "</a>
                    --------------------^

                    Comment

                    • jerrydigital
                      New Member
                      • Oct 2008
                      • 67

                      #11
                      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.as p code like this "</a>"", I receive the following error

                      ****Microsoft VBScript compilation error '800a0409'

                      Unterminated string constant

                      /registration.as p, 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.as p, 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?

                      Comment

                      • GazMathias
                        Recognized Expert New Member
                        • Oct 2008
                        • 228

                        #12
                        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.as p code like this "</a>"", I receive the following error

                        ****Microsoft VBScript compilation error '800a0409'

                        Unterminated string constant

                        /registration.as p, 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.as p, 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:

                        Code:
                        Response.Write "</a>
                        Can you post the updated code in its entirety?

                        Comment

                        • jerrydigital
                          New Member
                          • Oct 2008
                          • 67

                          #13
                          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.ds n. 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(Micr osoft Access Driver *.mdb), and i named this registration.ds n. 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.as p, line 10
                          ____

                          here is my updated code. i have a hosting account with godaddy, would this cause the problem?

                          Code:
                          <%@ 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>

                          Comment

                          • jhardman
                            Recognized Expert Specialist
                            • Jan 2007
                            • 3405

                            #14
                            try:
                            Code:
                            objConn.ConnectionString = "DSN=registration"

                            Comment

                            • jerrydigital
                              New Member
                              • Oct 2008
                              • 67

                              #15
                              Hi, thanks for you thoughts. However, using "DSN=registrati on" 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.as p, line 10

                              Comment

                              Working...