Automated Database Insert

Results 1 to 2 of 2

Thread: Automated Database Insert

  1. #1
    Jarrett Guest

    Default Automated Database Insert

    Hello, <BR>I have packed my shopping cart contents into a flat file and posted the information to the SSL server. The code works and inserts the information into the orders table, but it does not insert anything into the OrderDetails table, then it redirects to the proper page. I seems that the for next section is skipped. please help, I can&#039;t seem to find the problem<BR> <BR>Here is the code.<BR><BR>&#060;%<BR><BR>&#039;Insert Order Number and Customer Id from session variable into orders table.<BR>CartData = Session("svCartData")<BR>Set MM_Cmd = Server.CreateObject("ADODB.Command")<BR>MM_Cmd.Act iveConnection = "dsn=Scrubshirts;"<BR>MM_Cmd.CommandText = "INSERT INTO Orders(OrderID,CustomerID) VALUES (&#039;" & Session("OrderID") & "&#039;,&#039;" & Session("UserID") & "&#039;)"<BR>MM_Cmd.Execute<BR>&#039;Extract data from array format and insert into database.<BR>mycartarray=split(CartaData,"#")<BR>F or i=0 to ubound(mycartarray)<BR>myitemarray=split(mycartarr ay(i),"&#124")<BR>MM_Cmd.CommandText = "INSERT INTO OrderDetails(OrderID,TotalWeight,Weight,Color,Size ,ProductDetailID,Quantity,ProductName,UnitPrice,To tal) VALUES (&#039;" & Session("OrderID") & "&#039;,&#039;" & myitemarray(0) & "&#039;,&#039;" & myitemarray(1) & "&#039;,&#039;" & myitemarray(2) & "&#039;,&#039;" & myitemarray(3) & "&#039;,&#039;" & myitemarray(4) & "&#039;,&#039;" & myitemarray(5) & "&#039;,&#039;" & myitemarray(6) & "&#039;,&#039;" & myitemarray(7) & "&#039;,&#039;" & myitemarray(8) & "&#039;)"<BR>MM_Cmd.Execute<BR>Next<BR> direct "CheckOutView.asp"<BR><BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Automated Database Insert

    So how much debugging have you done?<BR><BR>Have you put in a *TON* of Response.Write calls to see where you are getting with what values?<BR><BR>Such as<BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write CartData<BR>right after you get the data from the session variable into that variable?<BR><BR>Such as<BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write ubound(MyCartArray) <BR>to see how many elements the SPLIT produced?<BR><BR>Such as<BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write MyCartArray(i)<BR>each time through the loop, to see what value each of those elements has?<BR><BR>Such as<BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write MM_Cmd.CommandText <BR>each time through the loop, to see exactly what SQL code you are trying to execute and whether it makes sense?<BR><BR>For starters, I see what *appear* to be 3 bugs. But until you do the DEBUGging, I can&#039;t be sure.<BR><BR>Oh...what the heck...I&#039;ll relent: How come you have &#039;...&#039; marks around values being inserted that appear, to my eyes, to be fields that *should* be numeric? Specifically, Quantity, UnitPrice, and Total? <BR><BR>What I don&#039;t understand, though, is why you aren&#039;t getting an error (or multiple errors) if that is the case. By any chance do you have an "ON ERROR RESUME NEXT" in your code? If so, dump it *now*! It is doing you a big disservice by masking your errors!<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