1 Reply Latest reply on Jul 28, 2008 9:05 AM by Newsgroup_User

    Need help understanding whats wrong with ASP checking for empty fields.

    Level 7
      Can anyone tell me whats wrong with these if statements: If i sumbit the
      form providing everything except the dream_inscript field it gives me this
      error:
      =================================================
      Microsoft OLE DB Provider for ODBC Drivers error '80040e57'
      [Microsoft][ODBC Microsoft Access Driver]Invalid string or buffer length

      /purch_confirm_mail.asp, line 67
      =================================================
      If i submit the form and provide just that field along with the first 4
      which are automatically passed from the DB the form submits fine and no
      problem.. I know it has something to do with my If Statements..

      Basically i want to check the 4 fields:

      dream_inscript If this one is -1 then pass N/A to the db
      dream_price If dream_inscript <> -1 then pass 45 to the db
      dream_comm if dream_comm is empty then pass N/A to the db

      custom_inscript if custom_inscript is empty then pass N/A to the db
      custom_wanted if this is Y then pass 45 to the db
      custom_comm if this is empty then pass N/A to the db




      MM_editCmd.CommandText = "INSERT INTO tbMailOrders (item_number,
      item_summary, item_price, shipping_cost, dream_price, dream_inscript,
      dream_comm, custom_comm, custom_price, video_wanted, video_price,
      grandtotal, cs_name, pp_email, c_email) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,
      ?, ?, ?, ?, ?, ?)"
      MM_editCmd.Prepared = true
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202,
      1, 10, Request.Form("item_number")) ' adVarWChar
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202,
      1, 255, Request.Form("item_summary")) ' adVarWChar
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202,
      1, 10, Request.Form("itemprice")) ' adVarWChar
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202,
      1, 10, Request.Form("shippingcost")) ' adVarWChar
      If cStr(Request.Form("dream_inscript"))<> "-1" Then
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1,
      10, "45") ' adVarWChar
      Else
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202,
      1, 10, "0.00") ' adVarWChar
      End If
      If cStr(Request.Form("dream_inscript"))<> "-1" Then
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 203, 1,
      1073741823, Request.Form("dream_inscript")) ' adLongVarWChar
      Else
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 203,
      1, 1073741823, "N/A") ' adLongVarWChar
      End If
      If Len(cStr(Request.Form("dream_comm")))= "0" Then
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 203,
      1, 1073741823, "N/A") ' adLongVarWChar
      Else
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 203,
      1, 1073741823, Request.Form("dream_comm")) ' adLongVarWChar
      End If
      If Len(cStr(Request.Form("custom_inscript")))= "0" Then
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 203,
      1, 1073741823, "N/A") ' adLongVarWChar
      Else
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 203, 1,
      1073741823, Request.Form("custom_inscript")) ' adLongVarWChar
      End If
      If Request.Form("custom_wanted")= "Y" Then
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202,
      1, 10, "45") ' adVarWChar
      Else
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202,
      1, 10, "0.00") ' adVarWChar
      End If
      If Request.Form("video_wanted")= "Y" Then
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202,
      1, 10, "Yes") ' adVarWChar
      Else
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202,
      1, 10, "No") ' adVarWChar
      End If
      If Request.Form("video_wanted")= "Y" Then
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1,
      10, "15") ' adVarWChar
      Else
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202,
      1, 10, 0.00) ' adVarWChar
      End If
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 202,
      1, 10, Request.Form("grand")) ' adVarWChar
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 202,
      1, 255, Request.Form("name")) ' adVarWChar
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 202,
      1, 255, Request.Form("email")) ' adVarWChar
      MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 202,
      1, 255, Request.Form("email2")) ' adVarWChar
      MM_editCmd.Execute
      MM_editCmd.ActiveConnection.Close

      --
      ************************************************
      ASP, SQL2005, DW8 VBScript, Access


        • 1. Re: Need help understanding whats wrong with ASP checking for empty fields.
          Level 7
          issue corrected.

          --
          ASP, SQL2005, DW8 VBScript, Visual Studio 2005, Visual Studio 2008
          "Daniel" <dan_c@h.com> wrote in message
          news:g6hghu$hld$1@forums.macromedia.com...
          > Can anyone tell me whats wrong with these if statements: If i sumbit the
          > form providing everything except the dream_inscript field it gives me this
          > error:
          > =================================================
          > Microsoft OLE DB Provider for ODBC Drivers error '80040e57'
          > [Microsoft][ODBC Microsoft Access Driver]Invalid string or buffer length
          >
          > /purch_confirm_mail.asp, line 67
          > =================================================
          > If i submit the form and provide just that field along with the first 4
          > which are automatically passed from the DB the form submits fine and no
          > problem.. I know it has something to do with my If Statements..
          >
          > Basically i want to check the 4 fields:
          >
          > dream_inscript If this one is -1 then pass N/A to the db
          > dream_price If dream_inscript <> -1 then pass 45 to the db
          > dream_comm if dream_comm is empty then pass N/A to the db
          >
          > custom_inscript if custom_inscript is empty then pass N/A to the db
          > custom_wanted if this is Y then pass 45 to the db
          > custom_comm if this is empty then pass N/A to the db
          >
          >
          >
          >
          > MM_editCmd.CommandText = "INSERT INTO tbMailOrders (item_number,
          > item_summary, item_price, shipping_cost, dream_price, dream_inscript,
          > dream_comm, custom_comm, custom_price, video_wanted, video_price,
          > grandtotal, cs_name, pp_email, c_email) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,
          > ?, ?, ?, ?, ?, ?)"
          > MM_editCmd.Prepared = true
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202,
          > 1, 10, Request.Form("item_number")) ' adVarWChar
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202,
          > 1, 255, Request.Form("item_summary")) ' adVarWChar
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202,
          > 1, 10, Request.Form("itemprice")) ' adVarWChar
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202,
          > 1, 10, Request.Form("shippingcost")) ' adVarWChar
          > If cStr(Request.Form("dream_inscript"))<> "-1" Then
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1,
          > 10, "45") ' adVarWChar
          > Else
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202,
          > 1, 10, "0.00") ' adVarWChar
          > End If
          > If cStr(Request.Form("dream_inscript"))<> "-1" Then
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 203, 1,
          > 1073741823, Request.Form("dream_inscript")) ' adLongVarWChar
          > Else
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 203,
          > 1, 1073741823, "N/A") ' adLongVarWChar
          > End If
          > If Len(cStr(Request.Form("dream_comm")))= "0" Then
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 203,
          > 1, 1073741823, "N/A") ' adLongVarWChar
          > Else
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 203,
          > 1, 1073741823, Request.Form("dream_comm")) ' adLongVarWChar
          > End If
          > If Len(cStr(Request.Form("custom_inscript")))= "0" Then
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 203,
          > 1, 1073741823, "N/A") ' adLongVarWChar
          > Else
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 203, 1,
          > 1073741823, Request.Form("custom_inscript")) ' adLongVarWChar
          > End If
          > If Request.Form("custom_wanted")= "Y" Then
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202,
          > 1, 10, "45") ' adVarWChar
          > Else
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202,
          > 1, 10, "0.00") ' adVarWChar
          > End If
          > If Request.Form("video_wanted")= "Y" Then
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202,
          > 1, 10, "Yes") ' adVarWChar
          > Else
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202,
          > 1, 10, "No") ' adVarWChar
          > End If
          > If Request.Form("video_wanted")= "Y" Then
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1,
          > 10, "15") ' adVarWChar
          > Else
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202,
          > 1, 10, 0.00) ' adVarWChar
          > End If
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 202,
          > 1, 10, Request.Form("grand")) ' adVarWChar
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 202,
          > 1, 255, Request.Form("name")) ' adVarWChar
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 202,
          > 1, 255, Request.Form("email")) ' adVarWChar
          > MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 202,
          > 1, 255, Request.Form("email2")) ' adVarWChar
          > MM_editCmd.Execute
          > MM_editCmd.ActiveConnection.Close
          >
          > --
          > ************************************************
          > ASP, SQL2005, DW8 VBScript, Access
          >