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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit Page

Status
Not open for further replies.

svsuthar1

Programmer
Jul 6, 2004
135
US
I have a submit page when I sent it goes through the SQL on the post page without any erros yet not posting to database.
I don't understand what could be the problem.


Here is the Submit page
<HTML><HEAD><BODY>
<!--#include virtual= "includes/commonheader.asp"-->
<SCRIPT LANGUAGE="JavaScript">
<!--
function SaveOrder()
{
document.forms[0].action = "saveInventory.asp";
document.forms[0].submit();
}
// -->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function ShowDate(oDoc,cDate)
{
window.open("/includes/datepicker.asp?backf="+oDoc+"&cDate="+cDate,"window", "height=210, width=300, resizeable=no,","");
}

// -->
</SCRIPT>

<LINK href="..\CSS\plone.css" type=text/css rel=stylesheet>
<FORM NAME=getInventory METHOD=post ACTION="saveInventory.asp">
<TABLE cellSpacing=0 cellPadding=1 border=1 align=center bordercolor="#CCCCCC" style='border-collapse:collapse;'>
<TR><TD align=center><B>Order #</B></TD>
<TD align=center><B>Product Name</B></TD>
<TD align=center><B>Price</B></TD>
<TD align=center><B>Quantity</B></TD>
<TD align=center><B>Action</B></TD>
<TD align=center><B>Order Date</B></TD>
</TR><BR></FORM>
<%
'Open up a connection our access database
'we will use a DSN-less connection

'Create a path for the database
Dim objConn, path
path="C:\Inetpub\
'Create a Connection using the path given above
Set objconn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString= "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & _
"DATA SOURCE=" & path
objConn.Open

'Create the SQL to be used for it to display
Dim strSQL, strSQL1, objRS, objRS1, iCount, ID, Code
iCount = 0
strSQL = "SELECT tblProducts.fldProductID, tblProducts.fldOrderNum, tblProducts.fldProductName, tblProducts.fldActive, tblCategory.fldCategoryID " _
& "FROM tblCategory INNER JOIN tblProducts ON tblCategory.fldCategoryID = tblProducts.fldCategoryID " _
& "WHERE (((tblProducts.fldActive)=Yes) AND ((tblCategory.fldCategoryID)=" & Request.QueryString("CategoryID")& "));"

strSQL1 = "SELECT fldActionID, fldActionName " _
& "FROM tblAction"

'Create a recordset of the SQL that is created above
Set objRS = Server.CreateObject("ADODB.Recordset")
'Set objRS1 = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn,3,3
'objRS1.Open strSQL1, objConn,3,3

'loop through all the records outputting a row for each one
Do Until objRS.EOF
Response.Write("<TR>")
Response.Write("<Input Type=Hidden Name=""" & iCount & ".ID"" " & _
"Value=""" & objRS("fldProductID") & """>")
Response.Write("<TD align=Center>" & objRS("fldOrderNum") & "</TD>")
Response.Write("<TD>" & objRS("fldProductName") & "</TD>")
Response.Write("<TD><input type=text name=""" & _
iCount & ".Price"" Value=0 STYLE=text-align:center></TD>")
Response.Write("<TD><input type=text name=""" & _
iCount & ".Quantity"" Value=0 STYLE=text-align:center></TD>")
Response.Write("<TD><Select name=""" & iCount & ".Action"">")
Set objRS1 = Server.CreateObject("ADODB.Recordset")
objRS1.Open strSQL1, objConn,3,3
Do Until objRS1.EOF
ID1 = objRS1("fldActionID")
Code = objRS1("fldActionName")
response.write("<option value='" & ID1 & "'>" & Code & "</option>")
objRS1.movenext
Loop
response.write("</select></td>")
objRS1.Close
set objRS1 = nothing
Response.Write("<TD><input type=text name=""" & _
iCount & ".Date"" Value=0 STYLE=text-align:center></TD>")

'Response.Write("<TD><input type name=""" & iCount & ".Date"" Value= & Res>
'Response.Write("<TD><input type=text name='Date' " & _
' iCount & ".Date"" Value= Resoponse.write(Date)>&nbsp;<A href=""javascript:ShowDate('getInventory.Date',this.getInventory.Date.value)""><IMG src=""..\images\help.gif"" align=middle border=0></A></TD>")
Response.Write("</TR>")
objRS.MoveNext
iCount = iCount + 1
Loop
'Clean up our ADO objects
objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing
Response.Write "<TR><TD Align=Center colspan=6><INPUT TYPE=BUTTON VALUE=""Submit"" ONCLICK=""SaveOrder();"" id=BUTTON1 name=BUTTON1></TD></TR>"
Response.Write "<INPUT TYPE=HIDDEN NAME=Count VALUE=" & iCount - 1 & ">"
%>
<!--#include virtual= "includes/commonheader2.asp"-->




Here is the Action page to save.


<!--#include virtual= "includes/commonheader.asp"-->
<LINK href="..\CSS\plone.css" type=text/css rel=stylesheet><BR>
<%
Response.Buffer = True
Dim iCount
iCount =Request("Count")

Dim strProductID, strPrice, strQuantity, strAction, strDate
'---------------------------Make a connection to the db--------------------------------------------------------
Dim objConn, path, SQL
path="C:\Inetpub\
'Create a Connection using the path given above
Set objconn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString= "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & _
"DATA SOURCE=" & path
objConn.Open

' Now, we want to loop through each form element
Dim iLoop
For iLoop = 0 To iCount
strProductID = Request(iLoop & ".ID")
strPrice = Request(iLoop & ".Price")
strQuantity = Request(iLoop & ".Quantity")
strAction = Request(iLoop & ".Action")
strDate = Request(iLoop & ".Date")

If (strQuantity <> 0) Then
SQL = "Insert into tblInventoryData (fldProductID, fldPrice, fldQuantity, fldActionID, fldDate) values (" _
& "'" & strProductID & "', " _
& "'" & strPrice & "', " _
& "'" & strQuantity & "', " _
& "'" & strAction & "', " _
& "'" & strDate & "')"
objConn.Execute(SQL)

End If
Next
Response.Write (SQL)
Response.Write("<TABLE Align=center border=0>")
Response.Write("<TR><TD><P>")
Response.Write("<CENTER><B>Your Infomration has been saved Successfully</B></CENTER>")
Response.Write("</P></TD></TR>")

'Clean up our ADO objects
objConn.Close
Set objConn = Nothing
%>
<!--#include virtual= "includes/commonheader2.asp"-->

I am not sure why it's not giving error's and not saving anything to the database.

any help appreciated.
 
The first thing I would do:
At the top of your Action page:
Code:
for each objItem in request.form()
   response.write(objItem & " = " & request.form(objItem) & "<BR>")
Next
That way you can see exactly what values you are getting. What does your SQL string look like. I see you are response.writing it in your code.
 
Thanks for your help.. No that did not seem to work...

Veep,

I will try your option first think monday and see what happens.

Again thank you so much for your help.


Samir
 
The form closing before the end of the input fields would be a crucial problem. To test, I like to output the SQL string. That would tell you if your field values are being retrieved and if the SQL string was actually executed.
 
Hey all,

I have tried the code below and the form is taking all the input forms correctly, but my Action form seems like is not picking up every single one.

for each objItem in request.form()
response.write(objItem & " = " & request.form(objItem) & "<BR>")
Next

My SQL only picked up the first inputs, but not the rest on SQL.

I hope this is useful
 
Thanks Veep, Your code let me see what was going through my form and Thanks HowardMarks I moved my </FORM> tag all the way at the end it works fine.

I really appreciate you help.

Samir
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top