Results 1 to 8 of 8

Thread: Help with ASP

  1. #1
    Join Date
    Jul 2003
    Posts
    45
    Rep Power
    0

    Default Help with ASP

    I have just recently started to experiment with ASP.
    I find it to be quite flexible and reusable.

    However I cannot get to connect to a database
    i keep getting this error

    Error Type:
    ADODB.Recordset (0x800A0BB9)
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

    Code:
    <%@LANGUAGE="VBSCRIPT" %>
     <html> 
      <head> 
      <title>PHONE BOOK</title> 
      </head> 
      <body bgcolor=black>
    
    <center> 
    <h2><font color="yellow">PHONE BOOK</font></h2>
      <font face="MS Gothic" > 
    
      <FORM NAME="PhoneBook" METHOD="GET" ACTION="phone.asp"> 
      <p> 
      <table border="1" bordercolor="green"> 
      <tr> 
      <td><font face="MS Gothic" color="yellow"><b>First Name:</b> </td> 
      <td><INPUT TYPE="TEXT" NAME="fname" VALUE="" SIZE="20" MAXLENGTH="25"></td> 
      </tr>
      <tr>
      <td><font face="MS Gothic" color="yellow"><b>Last Name:</b> </td> 
      <td><INPUT TYPE="TEXT" NAME="lname" VALUE="" SIZE="20" MAXLENGTH="25"></td> 
      </tr><tr> 
      <td><font face="MS Gothic" color="yellow"><b>Phone #:</b></td> 
      <td><INPUT TYPE="TEXT" NAME="phone" VALUE="" SIZE="11" MAXLENGTH="12"></td> 
      </tr>
    <tr> 
      <td><font face="MS Gothic" color="yellow"><b>Birthday:</b></td> 
      <td><INPUT TYPE="TEXT" NAME="dob" VALUE="" SIZE="11" MAXLENGTH="10"></td> 
      </tr>
       <tr> 
      <td><font face="MS Gothic" color="yellow"><b>E-mail :</b></td> 
      <td><INPUT TYPE="TEXT" NAME="email" VALUE="" SIZE="20" MAXLENGTH="25"></td> 
      </tr>
      <tr>
      
        <td><input type="CHECKBOX" name= "sex2" value="Male">      <font color="yellow"><b>Male</b><BR> </td><td><INPUT TYPE="CHECKBOX" NAME= "sex" VALUE="Female">
      <font color="yellow"><b>Female </b><BR></td>
      </tr> 
      </table> 
      
      <p> 
      <INPUT TYPE="SUBMIT" VALUE="Submit"> 
      <INPUT TYPE="RESET" VALUE="Clear "> 
      </p> 
      </form> 
    
      </font> 
    
    </center>
    <br>
    
    <% 
       dim strfname, strlname, strphone, stremail, strdob, strsex
       strfname =Server.HTMLEncode( Request.QueryString("fname")) 
       strlname =Server.HTMLEncode( Request.QueryString("lname")) 
       strphone =Server.HTMLEncode( Request.QueryString("phone")) 
       stremail =Server.HTMLEncode( Request.QueryString("email")) 
       strdob =Server.HTMLEncode( Request.QueryString("dob")) 
       strsex =Server.HTMLEncode( Request.QueryString("sex"))
    
    DIM objRS
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.Open "http://localhost/phonebook.mdb", objConn, , adLockOptimistic, adCmdTable
    
    objRS.AddNew
    objRS("fname") = Request.Form("fname")
    objRS("lname") = Request.Form("lname")
    objRS("phone") = Request.Form("phone")
    objRS("email") = Request.Form("email")
    objRS("dob") = Request.Form("dob")
    objRS("sex") = Request.Form("sex")
    objRS.Update
    
    objRS.Close
    Set objRS = Nothing
    objConn.Close
    Set objConn = Nothing
       
    
    
    'Display what was entered. 
       If ("" = strfname) OR ("" = strphone) Then 
         Response.Write "<font color=yellow><P>(Please Input relevant feilds)</P>" 
       Else 
         Response.Write "<font color=yellow>First Name: <b>" & strfname & "</b><br>"
         Response.Write "<font color=yellow>Last Name: <b>" & strlname & "</b><br>"
         Response.Write " <font color=yellow>Phone # <b>:" & strphone & "</b><br> "
         Response.Write "<font color=yellow>Email:<b> " & stremail & "</b><br> "
         Response.Write "<font color=yellow> Dob:<b> " & strdob  & "</b><br>"
         Response.Write "<font color=yellow> Sex: <b>" & strsex  & "</b><br></P>" 
       End If 
      %> 
    
      </body> 
      </html>

  2. #2
    Join Date
    Apr 2003
    Posts
    42
    Rep Power
    0

    Default Re:Help with ASP

    yow, kutchie

    review the syntax being use to open the result set. i believe you need to build a connection to the database which you call 'phonebook.mdb' where you have objCOnn, and where you have 'http://localhost/phonebook.mdb' you will use an sql query to work with the table of choice...


    hope it helps!!!

  3. #3
    Join Date
    Apr 2003
    Posts
    13,269
    Rep Power
    34

    Default Re:Help with ASP

    Didn't the error message give a line number?

    Also, it seems that no matter if the user is viewing or submiting the form, you are updating the database. So when you are just viewing the form, you are updating the database with blank info, since the form hasn't being submitted yet.

    You want to run the database update only after the user has submitted the form.

    You can try putting the following code around the database update section.

    Code:
    <% if Request.Form("SUBMIT") = "Submit" then
    ... your database code ...
    ... your database code ...
    ... your database code ...
    end if %>

  4. #4
    Join Date
    Apr 2003
    Posts
    13,269
    Rep Power
    34

    Default Re:Help with ASP

    I don't think you can use "http://" for the location of the database.

    Try using
    Code:
    objRS.Open "phonebook.mdb", objConn, , adLockOptimistic, adCmdTable
    if the database is in the same folder as the asp script.

  5. #5
    Join Date
    May 2004
    Posts
    3
    Rep Power
    0

    Default Re:Help with ASP

    You have that message because you have not yet connected to the database .

    The "Invalid argument" being referred to is your connection object (variable) which has not yet been set to anything

  6. #6
    Join Date
    Sep 2004
    Posts
    356
    Rep Power
    0

    Default Re: Help with ASP

    what kind of database connection you using I like to use dsn-less connection. What I do is to put the connection in a specific page and just include it in the page that needs the connection that way you have more controll

  7. #7
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default Re: Help with ASP

    another possibility is that you are try to assign a value of wrong type to a database column.

  8. #8
    Join Date
    Jun 2003
    Posts
    96
    Rep Power
    0

    Thumbs up Re: Help with ASP

    I think the connection string is invalid. You need to obtain the correct connection string.

    A good resource to check for information on ASP is W3schools.com http://www.w3schools.com/ado/ado_ref_connection.asp

    THis might be the code you need.

    set conn=Server.CreateObject("ADODB.Connection")
    conn.ConnectionString="Provider=Microsoft.Jet.OLED B.4.0"
    conn.open server.mappath("database.mdb")

    Delly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •