Error 80040e21 - Received when setting a new record's values

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Error 80040e21 - Received when setting a new record's values

    I am opening a connection to my Table via the recordset object. I have
    poured over it, but i can't seem to find the issue.

    I consistently receive the following error:
    ----------------------------------------------------------------------------
    --------------
    Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
    Multiple-step OLE DB operation generated errors. Check each OLE DB status
    value, if available. No work was done.
    /addEmployee.asp, line 49
    ------------------------------------------------------------
    And the code:

    The code is simple enough. I gather form data from the form that calls this
    page. I am opening a recordset and adding a new record. I am then
    populating the fields in the new record with the form data. Updating the
    table and closing. The only thing I haven't accounted for here is the field
    objRS("empID") which is an int(11) auto_increment field in the table. But I
    believe it will default to the next number, hence auto_increment(I'm open
    for clarification on this)?!?

    <%
    Option Explicit
    Dim strConnect
    %>
    <!-- #include file="DataStore.asp" -->
    <!-- #include file="adovbs.inc" -->
    <%
    Dim strFname, strLname, strMain, strAlt, strFax, strTitle, strEmail,
    strWebsite
    Dim objRS

    strFname = Request.Form("fname")
    strLname = Request.Form("lname")
    strMain = Request.Form("mainNum")
    strAlt = Request.Form("altNum")
    strFax = Request.Form("faxNum")
    strTitle = Request.Form("title")
    strEmail = Request.Form("email")
    strWebsite = Request.Form("website")

    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.Open "tblemployee", strConnect, adOpenForwardOnly, adLockOptimistic,
    adCmdTable

    objRS.AddNew

    objRS("empFirst") = strFname '<----------this is line 49 where the error
    is being thrown
    objRS("empLast") = strLname
    objRS("mainPhone") = strMain
    objRS("altPhone") = strAlt
    objRS("fax") = strFax
    objRS("title") = strTitle
    objRS("email") = strEmail
    objRS("website") = strWebsite
    objRS.Update

    objRS.Close
    Set objRS = Nothing

    Response.Write ("Sucess")
    %>
    ----------------------------------------------------------------------------
    ------
    And the connection string:

    <%
    strConnect="DRIVER={MySQL ODBC 3.51
    Driver};Server=localhost;Database=dbname;UID=usern ame;pwd=password;"
    %>
    ----------------------------------------------------------------------------
    -------

    It seems like this sequence should work. Any help anyone can offer would be
    greatly appreciated.

    Thanks,

    Jason


    Jason Kauffman Guest

  2. Similar Questions and Discussions

    1. How can I tell what setting was used to create a received PDF?
      I get PDFs all the time and I can't find a way of knowing if the PDF was created using Press Quality, Standard, Smallest File size other than just...
    2. Login User User Error 80040e21
      I am getting an 80040e21 error using the log in user server behavior. The complete error message is Microsoft OLE DB Provider for SQL Server...
    3. Error I received this morning...
      Can anyone tell me what this means? I have been running my server for several months and no problems. I just go this error.What do I need to fix...
    4. SQL error '80040e21' when adding more text than the Field can handle
      I have a field in a table called description. I set the lenght to 7000 characters and the datatype to char on the description field. Problem is...
    5. Newbie Question: Error Received
      Have you changed the NameSpace field under project properties - check upper/lower case Have you changed the name or location of the project? Have...
  3. #2

    Default Re: Error 80040e21 - Received when setting a new record's values


    "Jason Kauffman" <jkauffman22@attbi.com> wrote in message
    news:2fltb.1909$196.140505@news.uswest.net...
    > I am opening a connection to my Table via the recordset object. I have
    > poured over it, but i can't seem to find the issue.
    >
    > I consistently receive the following error:
    > --------------------------------------------------------------------------
    --
    > --------------
    > Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
    > Multiple-step OLE DB operation generated errors. Check each OLE DB status
    > value, if available. No work was done.
    > And the connection string:
    >
    > <%
    > strConnect="DRIVER={MySQL ODBC 3.51
    > Driver};Server=localhost;Database=dbname;UID=usern ame;pwd=password;"
    > %>

    Switch to an OLEDB connection, and you should get a better error than that
    one.
    strConnect="Provider=MySQLProv;Data Source=dbname;User
    Id=username;Password=password;"




    > ------------------------------------------------------------
    > And the code:
    > Set objRS = Server.CreateObject("ADODB.Recordset")
    > objRS.Open "tblemployee", strConnect, adOpenForwardOnly, adLockOptimistic,
    > adCmdTable
    >
    > objRS.AddNew
    >
    > objRS("empFirst") = strFname '<----------this is line 49 where the
    error
    <snip>
    > objRS.Close
    > Set objRS = Nothing
    >
    Instead of creating a recordset and doing things this way, just execute an
    INSERT.
    strFname = Replace(strFname, "'", "''")
    sSQL = "INSERT INTO [tblemployee] ([empFirst]) VALUES ('" & strFname & "')"
    Set oADO = Server.CreateObject("ADODB.Connection")
    oADO.Open strConnection
    oADO.Execute sSQL
    oADO.Close : Set oADO = Nothing

    Ray at home



    Ray at Guest

  4. #3

    Default Re: Error 80040e21 - Received when setting a new record's values

    Jason Kauffman wrote:
    > I am opening a connection to my Table via the recordset object.
    What database?
    > I have poured over it, but i can't seem to find the issue.
    >
    > I consistently receive the following error:
    > --------------------------------------------------------------------------
    --
    > --------------
    > Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
    > Multiple-step OLE DB operation generated errors. Check each OLE DB
    > status value, if available. No work was done.
    > /addEmployee.asp, line 49
    > ------------------------------------------------------------
    >
    > strFname = Request.Form("fname")
    > strLname = Request.Form("lname")
    > strMain = Request.Form("mainNum")
    > strAlt = Request.Form("altNum")
    > strFax = Request.Form("faxNum")
    > strTitle = Request.Form("title")
    > strEmail = Request.Form("email")
    > strWebsite = Request.Form("website")
    >
    In addition to Ray's good advice, you should verify that these variables
    contain values before attempting to write them into your database,
    especially if any of your columns do not allow Nulls or zero-length strings.

    HTH,
    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  5. #4

    Default Re: Error 80040e21 - Received when setting a new record's values

    Ray,

    Thanks for your help. The INSERT statement worked much better than using
    addNew with a Recordset. Is the Replace() function replacing all single
    quotes with double-single quotes, so that the INSERT statement won't throw
    an error? At any rate, I appreciate the help.

    Jason
    "Jason Kauffman" <jkauffman22@attbi.com> wrote in message
    news:2fltb.1909$196.140505@news.uswest.net...
    > I am opening a connection to my Table via the recordset object. I have
    > poured over it, but i can't seem to find the issue.
    >
    > I consistently receive the following error:
    > --------------------------------------------------------------------------
    --
    > --------------
    > Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
    > Multiple-step OLE DB operation generated errors. Check each OLE DB status
    > value, if available. No work was done.
    > /addEmployee.asp, line 49
    > ------------------------------------------------------------
    > And the code:
    >
    > The code is simple enough. I gather form data from the form that calls
    this
    > page. I am opening a recordset and adding a new record. I am then
    > populating the fields in the new record with the form data. Updating the
    > table and closing. The only thing I haven't accounted for here is the
    field
    > objRS("empID") which is an int(11) auto_increment field in the table. But
    I
    > believe it will default to the next number, hence auto_increment(I'm open
    > for clarification on this)?!?
    >
    > <%
    > Option Explicit
    > Dim strConnect
    > %>
    > <!-- #include file="DataStore.asp" -->
    > <!-- #include file="adovbs.inc" -->
    > <%
    > Dim strFname, strLname, strMain, strAlt, strFax, strTitle, strEmail,
    > strWebsite
    > Dim objRS
    >
    > strFname = Request.Form("fname")
    > strLname = Request.Form("lname")
    > strMain = Request.Form("mainNum")
    > strAlt = Request.Form("altNum")
    > strFax = Request.Form("faxNum")
    > strTitle = Request.Form("title")
    > strEmail = Request.Form("email")
    > strWebsite = Request.Form("website")
    >
    > Set objRS = Server.CreateObject("ADODB.Recordset")
    > objRS.Open "tblemployee", strConnect, adOpenForwardOnly, adLockOptimistic,
    > adCmdTable
    >
    > objRS.AddNew
    >
    > objRS("empFirst") = strFname '<----------this is line 49 where the
    error
    > is being thrown
    > objRS("empLast") = strLname
    > objRS("mainPhone") = strMain
    > objRS("altPhone") = strAlt
    > objRS("fax") = strFax
    > objRS("title") = strTitle
    > objRS("email") = strEmail
    > objRS("website") = strWebsite
    > objRS.Update
    >
    > objRS.Close
    > Set objRS = Nothing
    >
    > Response.Write ("Sucess")
    > %>
    > --------------------------------------------------------------------------
    --
    > ------
    > And the connection string:
    >
    > <%
    > strConnect="DRIVER={MySQL ODBC 3.51
    > Driver};Server=localhost;Database=dbname;UID=usern ame;pwd=password;"
    > %>
    > --------------------------------------------------------------------------
    --
    > -------
    >
    > It seems like this sequence should work. Any help anyone can offer would
    be
    > greatly appreciated.
    >
    > Thanks,
    >
    > Jason
    >
    >

    Jason Kauffman Guest

  6. #5

    Default Re: Error 80040e21 - Received when setting a new record's values

    Yes, the replace is so that you don't wind up with something like:

    INSERT INTO [Restaurants] ([ResterauntName]) VALUES ('Joe's Chicken Shack')

    That ' in Joe's would mess things up. The way to insert a ' is by doubling
    it in your sql string.

    Ray at home

    "Jason Kauffman" <jkauffman22@attbi.com> wrote in message
    news:nettb.49$7Q.19731@news.uswest.net...
    > Ray,
    >
    > Thanks for your help. The INSERT statement worked much better than using
    > addNew with a Recordset. Is the Replace() function replacing all single
    > quotes with double-single quotes, so that the INSERT statement won't throw
    > an error? At any rate, I appreciate the help.
    >
    > Jason

    Ray at Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139