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)> <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.
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)> <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.