Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Elements to a DB listbox

Status
Not open for further replies.

onpnt

Programmer
Dec 11, 2001
7,778
US
I'm writing a cart to send the selected item from a item box to a database. I (with the help of programmers here) read the data from the DB adn populated the item boxes but when I go to addNew them to the database I get nothing. Empty fields. Anyone have any ideas on what I'm doing wrong. Thanks
here's the code:

'create arrays
DIM ProcArray()
DIM ProcPriceArray()
REDIM ProcArray(4)
REDIM ProcPriceArray(4)
DIM printerArray()
DIM printerPriceArray()
REDIM printerArray(4)
REDIM printerPriceArray(4)
DIM discArray()
DIM discPriceArray()
REDIM discArray(4)
REDIM discPriceArray(4)
DIM optArray()
DIM optPriceArray()
REDIM optArray(4)
REDIM optPriceArray(4)


strProc=&quot;<SELECT name='proc'>&quot;
strDisc=&quot;<SELECT name='disc'>&quot;
strPrinter=&quot;<SELECT name='printer'>&quot;
strOpt=&quot;<SELECT name='opt'>&quot;

strTbl2=&quot;<TABLE bgcolor=#996600 border=1 cellpadding=5 cellspacing=5>&quot;
strTbl=&quot;<table bgcolor=#996600 border=0 cellpadding=5 cellspacing=5>&quot;
strTblend=&quot;</TABLE>&quot;
strrow=&quot;<TR>&quot;
strrowend=&quot;</TR>&quot;
strcol=&quot;<TD>&quot;
strcolend=&quot;</TD>&quot;

DO UNTIL Recordset.EOF

if Recordset(&quot;PartCode&quot;) = &quot;P&quot; Then
ProcArray(x)=Recordset(&quot;PartDesc&quot;)
ProcPriceArray(x)=Recordset(&quot;Price&quot;)

strProc=strProc & &quot;<OPTION>&quot;
strProc=strProc & ProcArray(x) & &quot; &quot;
strProc=strProc & &quot;$&quot; & ProcPriceArray(x)
strProc=strProc & &quot;</OPTION>&quot;

elseif Recordset(&quot;PartCode&quot;) = &quot;H&quot; Then
discArray(x)=Recordset(&quot;PartDesc&quot;)
discPriceArray(x)=Recordset(&quot;Price&quot;)

strDisc=strDisc & &quot;<OPTION>&quot;
strDisc=strDisc & discArray(x) & &quot; &quot;
strDisc=strDisc & &quot;$&quot; & discPriceArray(x)
strDisc=strDisc & &quot;</OPTION>&quot;

elseif Recordset(&quot;PartCode&quot;) = &quot;R&quot; Then
printerArray(x)=Recordset(&quot;PartDesc&quot;)
printerPriceArray(x)=Recordset(&quot;Price&quot;)

strPrinter=strPrinter & &quot;<OPTION>&quot;
strPrinter=strPrinter &printerArray(x) & &quot; &quot;
strPrinter=strPrinter & &quot;$&quot; & printerPriceArray(x)
strPrinter=strPrinter &&quot;</OPTION>&quot;

elseif Recordset(&quot;PartCode&quot;) = &quot;O&quot; Then
optArray(x)=Recordset(&quot;PartDesc&quot;)
optPriceArray(x)=Recordset(&quot;Price&quot;)

strOpt=strOpt & &quot;<OPTION>&quot;
strOpt=strOpt & optArray(x) & &quot; &quot;
strOpt=strOpt & &quot;$&quot; & optPriceArray(x)
strOpt=strOpt & &quot;</OPTION>&quot;

end if

Recordset.MoveNext
Loop

strEndSelect=&quot;</SELECT>&quot;
Response.Write(strTbl)
Response.Write(strrow)
Response.Write(strcol)
Response.Write(strProc & strEndSelect)
Response.Write(strcolend)
Response.Write(strcol)
Response.Write(strDisc & strEndSelect)
Response.Write(strcolend)

Response.Write(strrowend)
Response.Write(strrow)

Response.Write(strcol)
Response.Write(strPrinter & strEndSelect)
Response.Write(strcolend)
Response.Write(strcol)
Response.Write(strOpt & strEndSelect)
Response.Write(strcolend)
Response.Write(strrowend)
Response.Write(strTblend)
%>
<%
'close the database and set connection to nothing
connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

Here's where I do teh adding to the DB

set conn = server.createobject(&quot;adodb.connection&quot;)
conn.open &quot;DSN=orders&quot;

DIM idNum
idnum=((Application(&quot;countusers&quot;) & 3) & &quot;18&quot;)
Set Recordset=Server.CreateObject(&quot;ADODB.Recordset&quot;)
Recordset.Open &quot;tblOrder&quot;, conn, 1, 2
Recordset.AddNew
Recordset(&quot;OrderNum&quot;)=(idNum)

Recordset(&quot;Processor&quot;)=Request.Form(&quot;proc&quot;)

Recordset(&quot;Optical&quot;)=Request.Form(&quot;opt&quot;)

Recordset(&quot;RAM&quot;)=Request.Form(&quot;printer&quot;)

Recordset(&quot;HardDrive&quot;)=Request.Form(&quot;disc&quot;)

Recordset(&quot;TotalCost&quot;)=Request.Form(&quot;total&quot;)

Recordset(&quot;Address&quot;)=Request.Form(&quot;email&quot;) provide tools to let people become their best.
 
did you include Recordset.update
since rollback is included your new data is not written until you update.(a good time to include error checking routines.
 
I did include the recordset.update and I have a page written to redirect in case of errors occure. I tried to simply write the form fields for the item box and they would not go even with that. I have a feeling I'm jsut calling them wrong but I'm at a loss at what I should be calling. I tried
Request.Form(&quot;proc&quot;)
Request.Form(&quot;strProc&quot;)
even took a crack at Request.Form(&quot;procArray(x)&quot;) new that one wouldn't work. provide tools to let people become their best.
 
I finally found my faily stupid mistake. I had my <FORM> tags outside the parameters of the item boxes. This goes to show your formatting is ever so important. provide tools to let people become their best.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top