I still need help!

Results 1 to 2 of 2

Thread: I still need help!

  1. #1
    Join Date
    Dec 1969

    Default I still need help!

    Yesterday I posted the message below - I was advised to insert something like &#039;if strvariable = "" then Null&#039;<BR>but I dont understand where I should put this, and what variable it refers to - please help!<BR><BR>Im using Macromedia Dreamweaver Ultradev to create a &#039;shopping cart&#039; website<BR>with an Access database. I need to insert the username( from a session<BR>variable) and the productID into the &#039;Cart&#039; table, but keep getting this<BR>error<BR><BR>&#039;Microsoft OLE DB Provider for ODBC Drivers error &#039;80040e14&#039;<BR><BR>[Microsoft][ODBC Microsoft Access Driver] Number of query values and<BR>destination fields are not the same.<BR><BR>I need to leave the other database fields blank (cartId - autonumber should<BR>generate this, OrderID - to be added at next page, Total - to be added at<BR>next page).<BR><BR>Since Ultradev has generated the ASP code, Im having problems understanding<BR>it, this is the code - ending where the error occurs:<BR>&#060;%@LANGUAGE="VBSCRIPT"%&#062;&#060 ;%<BR>&#039; *** Insert Record: construct a sql insert statement and execute it<BR>MM_editAction = CStr(Request("URL"))<BR>If (Request.QueryString &#060;&#062; "") Then<BR> MM_editAction = MM_editAction & "?" & Request.QueryString<BR>End If<BR>If (CStr(Request("MM_insert")) &#060;&#062; "") Then<BR><BR> MM_tableName = "Cart"<BR> MM_fields = "ProductId,ProductId,&#039;,none,&#039;&#039;" <BR> MM_redirectPage = "checkout.asp"<BR><BR> &#039; create the insert sql statement<BR> MM_tableValues = ""<BR> MM_dbValues = ""<BR> MM_fieldsArray = Split(MM_fields, ",")<BR> For i = LBound(MM_fieldsArray) To UBound(MM_fieldsArray) Step 5<BR> FormVal = CStr(Request.Form(MM_fieldsArray(i)))<BR> Delim = MM_fieldsArray(i+2)<BR> If (Delim = "none") Then Delim = ""<BR> AltVal = MM_fieldsArray(i+3)<BR> If (AltVal = "none") Then AltVal = ""<BR> EmptyVal = MM_fieldsArray(i+4)<BR> If (EmptyVal = "none") Then EmptyVal = ""<BR> If (FormVal = "") Then<BR> FormVal = EmptyVal<BR> Else<BR> If (AltVal &#060;&#062; "") Then<BR> FormVal = AltVal<BR> ElseIf (Delim = "&#039;") Then &#039; escape quotes<BR> FormVal = "&#039;" & Replace(FormVal,"&#039;","&#039;&#039;") & "&#039;"<BR> Else<BR> FormVal = Delim + FormVal + Delim<BR> End If<BR> End If<BR> If (i &#060;&#062; LBound(MM_fieldsArray)) Then<BR> MM_tableValues = MM_tableValues & ","<BR> MM_dbValues = MM_dbValues & ","<BR> End if<BR> MM_tableValues = MM_tableValues & MM_fieldsArray(i+1)<BR> MM_dbValues = MM_dbValues & FormVal<BR> Next<BR> strUsername = Session("MM_Username")<BR> MM_insertStr = "insert into " & MM_tableName & " values(&#039;&#039;," & MM_dbValues<BR>& "," & strUsername &&#039;&#039;,&#039;&#039;)"<BR><BR> &#039; finish the sql and execute it<BR> Set MM_insertCmd = Server.CreateObject("ADODB.Command")<BR> MM_insertCmd.ActiveConnection = "DRIVER={Microsoft Access Driver<BR>(*.mdb)};DBQ=c:my documentsprojectsystem
    orfolk.mdb "<BR> MM_insertCmd.CommandText = MM_insertStr<BR> MM_insertCmd.Execute<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Basics of SQL...

    Look here:<BR><BR>http://w3.one.net/~jhoffman/sqltut.htm<BR><BR>You are getting that error because you are using the "shorthand" form of the INSERT statement. That is, you are *not* listing the field names of the fields that you are trying to assign values to. When you use that "shorthand" form, you *MUST* then supply a value for *EVERY* field (no exceptions!) and you *MUST* supply them in the order they appear in the schema.<BR><BR>In short, I would recommend that you learn about the other form of INSERT, where you have much more flexibility.<BR><BR>

Posting Permissions

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