Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Question Unanswered: Insert Record Error

    I have an form that takes in some information, and then calls confirm.asp to insert the record into my database.

    I get 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.
    /confirm.asp, line 10

    Here is my confirm.asp

    Code:
    <%
    dim objConn
    Set objConn=Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db\testdb.mdb")&";"
    objConn.Open 
    
    dim objRS
    Set objRS=Server.CreateObject("ADODB.Recordset")
    objRS.Open "tblContact",objConn,,adLockOptimistic,adCmdTable
    
    objRS.AddNew
    objRS("Email")=Request.Form("Email")
    objRS("FirstName")=Request.Form("FirstName")
    objRS("LastName")=Request.Form("LastName")
    objRS("Comments")=Request.Form("Comments")
    objRS("DateContacted")=Date()
    objRS.Update
    %>
    <p>
    <%
    dim strFirstName
    strFirstName = Request.Form("FirstName")
    %>
    <br>
    </p>
    <%
    objRS.Close
    set objRS=Nothing
    objConn.Close
    set objConn=Nothing
    %>
    Thanks.

  2. #2
    Join Date
    Feb 2004
    Posts
    9

    Re: Insert Record Error

    Have you tried an insert command instead? try the following code:
    Code:
    <%
    dim RS
    dim objConn
    Set objConn=Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db\testdb.mdb")&";"
    objConn.Open 
    
    sql = "insert into tblContact(Email, FirstName, LastName, Comments) values('"&request("Email")&"','"&request("FirstName")&"','"&request("LastName")&"','"&request("Comments")&'");"
    set RS=Conn.Execute(sql)
    %>
    <p>
    <%
    dim strFirstName
    strFirstName = Request.Form("FirstName")
    %>
    <br>
    </p>
    <%
    objConn.Close
    set objConn=Nothing
    %>
    Hope this helps....

  3. #3
    Join Date
    Feb 2004
    Posts
    9
    oops i made a mistake
    change set RS=Conn.Execute(sql) to set RS=objConn.Execute(sql)

  4. #4
    Join Date
    Mar 2004
    Posts
    3
    Code:
    <%
    dim objRS
    dim objConn
    Set objConn=Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db\testdb.mdb")&";"
    objConn.Open 
    
    sql = "insert into tblContact(Email, FirstName, LastName, Comments) values('"&request("Email")&"','"&request("FirstName")&"','"&request("LastName")&"','"&request("Comments")&"');"
    set objRS = objConn.Execute(sql)
    %>
    <p>
    <%
    dim strFirstName
    strFirstName = Request.Form("FirstName")
    %>
    <br>
    </p>
    <%
    objConn.Close
    set objConn=Nothing
    %>
    I now get:

    Microsoft JET Database Engine (0x80004005)
    Operation must use an updateable query.
    /confirm.asp, line 9

  5. #5
    Join Date
    Mar 2004
    Posts
    6
    I usually set up my object a little different...try this:

    Code:
    Dim dsn
    set dsn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db\testdb.mdb")&";"
    
    Dim oconn
    set oconn=server.CreateObject("adodb.connection")
    oconn.open,dsn 
    
    dim objRS
    set objRS= createobject("ADODB.Recordset")
    objRS.CursorType = 1
    objRS.LockType = 3
    objRS.Source = "tblContact"
    objRS.Open,oconn
    
    objRS.AddNew
    objRS("Email")=request("Email")
    objRS("FirstName")=request("FirstName")
    objRS("LastName")=request("LastName")
    objRS("Comments")=request("Comments")
    objRS("DateContacted")=Date()
    objRS.Update
    objRS.Close
    set objRS=Nothing
    oconn.Close
    set oconn=Nothing
    ...subtle differences, but this works for me every time.

Posting Permissions

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