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!

NEWBIE STILL NEEDS HELP (Outputing Information)

Status
Not open for further replies.

ScottNomus

Programmer
Jun 27, 2001
33
US
I am still working on a Web based database using ASP.
I have several forms that I am having to create. The code that will be listed below is on the 1st form. The customer enters in information and click the submit button. When they do this it needs to query the database and give them an output of open sales orders.
I need to figure out how to get the submit button to do this and send it to another page.

****I AM STILL REAL NEW TO THSI SO ANY HELP IS WELCOMED****
If you need to see anything else let me know and I will get it to you.

**********HERE IS THE PAGE**************
<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/WebCustomer.asp&quot; -->
<%
set Inquiry_1 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Inquiry_1.ActiveConnection = MM_WebCustomer_STRING
Inquiry_1.Source = &quot;SELECT Customer FROM open_so_inq&quot;
Inquiry_1.CursorType = 0
Inquiry_1.CursorLocation = 2
Inquiry_1.LockType = 3
Inquiry_1.Open()
Inquiry_1_numRows = 0
%>
<%
set ShipToCode = Server.CreateObject(&quot;ADODB.Recordset&quot;)
ShipToCode.ActiveConnection = MM_WebCustomer_STRING
ShipToCode.Source = &quot;SELECT ShipToCode FROM open_so_inq&quot;
ShipToCode.CursorType = 0
ShipToCode.CursorLocation = 2
ShipToCode.LockType = 3
ShipToCode.Open()
ShipToCode_numRows = 0
%>
<%
set ItemNumber = Server.CreateObject(&quot;ADODB.Recordset&quot;)
ItemNumber.ActiveConnection = MM_WebCustomer_STRING
ItemNumber.Source = &quot;SELECT ItemNumber FROM open_so_inq&quot;
ItemNumber.CursorType = 0
ItemNumber.CursorLocation = 2
ItemNumber.LockType = 3
ItemNumber.Open()
ItemNumber_numRows = 0
%>
<%
set City = Server.CreateObject(&quot;ADODB.Recordset&quot;)
City.ActiveConnection = MM_WebCustomer_STRING
City.Source = &quot;SELECT ShipToCity FROM open_so_inq&quot;
City.CursorType = 0
City.CursorLocation = 2
City.LockType = 3
City.Open()
City_numRows = 0
%>
<%
set States = Server.CreateObject(&quot;ADODB.Recordset&quot;)
States.ActiveConnection = MM_WebCustomer_STRING
States.Source = &quot;SELECT statename FROM states&quot;
States.CursorType = 0
States.CursorLocation = 2
States.LockType = 3
States.Open()
States_numRows = 0
%>
<%
set PONumber = Server.CreateObject(&quot;ADODB.Recordset&quot;)
PONumber.ActiveConnection = MM_WebCustomer_STRING
PONumber.Source = &quot;SELECT PONumber FROM open_so_inq&quot;
PONumber.CursorType = 0
PONumber.CursorLocation = 2
PONumber.LockType = 3
PONumber.Open()
PONumber_numRows = 0
%>
<%
set ShiptoName = Server.CreateObject(&quot;ADODB.Recordset&quot;)
ShiptoName.ActiveConnection = MM_WebCustomer_STRING
ShiptoName.Source = &quot;SELECT ShipToName FROM open_so_inq&quot;
ShiptoName.CursorType = 0
ShiptoName.CursorLocation = 2
ShiptoName.LockType = 3
ShiptoName.Open()
ShiptoName_numRows = 0
%>
<%
set Addr1 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Addr1.ActiveConnection = MM_WebCustomer_STRING
Addr1.Source = &quot;SELECT ShipToAddress1 FROM open_so_inq&quot;
Addr1.CursorType = 0
Addr1.CursorLocation = 2
Addr1.LockType = 3
Addr1.Open()
Addr1_numRows = 0
%>
<%
set Addr2 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Addr2.ActiveConnection = MM_WebCustomer_STRING
Addr2.Source = &quot;SELECT ShipToAddress2 FROM open_so_inq&quot;
Addr2.CursorType = 0
Addr2.CursorLocation = 2
Addr2.LockType = 3
Addr2.Open()
Addr2_numRows = 0
%>
<%
set Filter_Query = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Filter_Query.ActiveConnection = MM_WebCustomer_STRING
Filter_Query.Source = &quot;SELECT * FROM open_so_inq&quot;
Filter_Query.CursorType = 0
Filter_Query.CursorLocation = 2
Filter_Query.LockType = 3
Filter_Query.Open()
Filter_Query_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot;>
<div align=&quot;center&quot;>
<p><img src=&quot;Images/Nomus%20Logo%20.JPG&quot; width=&quot;335&quot; height=&quot;256&quot;> </p>
<form method=&quot;post&quot; action=&quot;&quot;>
<table width=&quot;668&quot; border=&quot;0&quot;>
<tr>
<td>Customer</td>
<td>
<select name=&quot;select&quot;>
<%
While (NOT Inquiry_1.EOF)
%>
<option value=&quot;<%=(Inquiry_1.Fields.Item(&quot;Customer&quot;).Value)%>&quot; ><%=(Inquiry_1.Fields.Item(&quot;Customer&quot;).Value)%></option>
<%
Inquiry_1.MoveNext()
Wend
If (Inquiry_1.CursorType > 0) Then
Inquiry_1.MoveFirst
Else
Inquiry_1.Requery
End If
%>
</select>
</td>
<td>Ship to Name</td>
<td>
<input type=&quot;text&quot; name=&quot;textfield2&quot; value=&quot;<%=(ShiptoName.Fields.Item(&quot;ShipToName&quot;).Value)%>&quot;>
</td>
<td>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Filter&quot;>
</td>
</tr>
<tr>
<td>Ship To Code</td>
<td>
<select name=&quot;select2&quot;>
<%
While (NOT ShipToCode.EOF)
%>
<option value=&quot;<%=(ShipToCode.Fields.Item(&quot;ShipToCode&quot;).Value)%>&quot; ><%=(ShipToCode.Fields.Item(&quot;ShipToCode&quot;).Value)%></option>
<%
ShipToCode.MoveNext()
Wend
If (ShipToCode.CursorType > 0) Then
ShipToCode.MoveFirst
Else
ShipToCode.Requery
End If
%>
</select>
</td>
<td>Addr 1</td>
<td>
<input type=&quot;text&quot; name=&quot;textfield3&quot; value=&quot;<%=(Addr1.Fields.Item(&quot;ShipToAddress1&quot;).Value)%>&quot;>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Item Number</td>
<td>
<select name=&quot;select3&quot;>
<%
While (NOT ItemNumber.EOF)
%>
<option value=&quot;<%=(ItemNumber.Fields.Item(&quot;ItemNumber&quot;).Value)%>&quot; ><%=(ItemNumber.Fields.Item(&quot;ItemNumber&quot;).Value)%></option>
<%
ItemNumber.MoveNext()
Wend
If (ItemNumber.CursorType > 0) Then
ItemNumber.MoveFirst
Else
ItemNumber.Requery
End If
%>
</select>
</td>
<td>Addr 2</td>
<td>
<input type=&quot;text&quot; name=&quot;textfield4&quot; value=&quot;<%=(Addr2.Fields.Item(&quot;ShipToAddress2&quot;).Value)%>&quot;>
</td>
<td>
<input type=&quot;submit&quot; name=&quot;Submit4&quot; value=&quot;Exit&quot;>
</td>
</tr>
<tr>
<td>PO Number</td>
<td>
<input type=&quot;text&quot; name=&quot;textfield&quot; value=&quot;<%=(PONumber.Fields.Item(&quot;PONumber&quot;).Value)%>&quot;>
</td>
<td>City</td>
<td>
<input type=&quot;text&quot; name=&quot;textfield5&quot; value=&quot;<%=(City.Fields.Item(&quot;ShipToCity&quot;).Value)%>&quot;>
</td>
<td>&nbsp; </td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>State</td>
<td>
<select name=&quot;select4&quot;>
<%
While (NOT States.EOF)
%>
<option value=&quot;<%=(States.Fields.Item(&quot;statename&quot;).Value)%>&quot; ><%=(States.Fields.Item(&quot;statename&quot;).Value)%></option>
<%
States.MoveNext()
Wend
If (States.CursorType > 0) Then
States.MoveFirst
Else
States.Requery
End If
%>
</select>
</td>
<td>&nbsp; </td>
</tr>
</table>
</form>
<p>&nbsp; </p>
</div>
</body>
</html>
<%
Inquiry_1.Close()
%>
<%
ShipToCode.Close()
%>
<%
ItemNumber.Close()
%>
<%
City.Close()
%>
<%
States.Close()
%>
<%
PONumber.Close()
%>
<%
ShiptoName.Close()
%>
<%
Addr1.Close()
%>
<%
Addr2.Close()
%>
<%
Filter_Query.Close()
%>
 
Well, first off, I wouldn't put the database code on the same page as the form. It should go to the page the results will display. The &quot;ACTION&quot; in the form tag should say the name of the page you want to take the user to once the button is clicked.

I'm new at this too but I have made forms work with my database so far. Someone else might have better idea than me. Mary :)

Rule 1: Don't sweat the small stuff.
Rule 2: EVERYTHING is small stuff!! X-)
 
Hey where are these pages located? I am doing something similar, and would love to get a look at what you have there.
 

ScottNomus,

I'm not sure what your doing with the several calls to recordsets but you can shorten your logic by creating functions that do repetitive tasks.

GetConnection() and GetTable() are functions in another ASP INCLUDE File called utilities.asp

' Utiltities.ASP
'--------------------------
' ************************
Function GetConnection()
' ************************
Dim strCn, CnTmp

const SQL_Svr = &quot;YourServerName&quot;

const DBase = &quot;databaseName&quot;
const UID = &quot;YourUID&quot;
const PASSWORD = &quot;YourPassword&quot;

strConn = &quot;PROVIDER=SQLOLEDB;&quot; & _
&quot;DRIVER={SQL Server};&quot; & _
&quot;SERVER=&quot; & SQL_Svr & &quot;;&quot; & _
&quot;DATABASE=&quot; & DBase & &quot;;&quot; & _
&quot;UID=&quot; & UID & &quot;;&quot; & _
&quot;PWD=&quot; & PASSWORD

Set CnTmp = CreateObject(&quot;ADODB.Connection&quot;)
CnTmp.open strConn
Set GetConnection = CnTmp
End Function
'
' ********************************
Function GetTable(CnTmp, strSQL)
' ********************************
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4

Set rsTmp = CreateObject(&quot;ADODB.Recordset&quot;)
' rsTmp.Open Source,ActiveConnection,CursorType, LockType,Options
rsTmp.open strSQL, CnTmp, adOpenKeyset, adLockOptimistic
Set GetTable = rsTmp
End function
'

You will also need a file called adovbs.inc for cursor types
Put this in the <HEAD> of your ASP page.
<!-- #include file=&quot;adovbs.inc&quot; -->
<!-- #include file=&quot;utilities.asp&quot; -->

From your logic, it looks like you only need to make a call to one recordset to get the fields, but you are making several calls to get individual fields????

This is a shortened version of your logic:
Cheers,
fengshui1998
-----------------------------------------------------

<%
Set Cn = GetConnection()
Set Inquiry_1 = GetTable(Cn, &quot;SELECT Customer FROM open_so_inq&quot;)
Set ShipToCode = GetTable(Cn, &quot;SELECT ShipToCode FROM open_so_inq&quot;)
Set ItemNumber = GetTable(Cn, &quot;SELECT ItemNumber FROM open_so_inq&quot;)
Set City = GetTable(Cn, &quot;SELECT ShipToCity FROM open_so_inq&quot;)
Set States = GetTable(Cn, &quot;SELECT statename FROM states&quot;)
Set PONumber = GetTable(Cn, &quot;SELECT PONumber FROM open_so_inq&quot;)
Set ShiptoName = GetTable(Cn, &quot;SELECT ShipToName FROM open_so_inq&quot;)
Set Addr1 = GetTable(Cn, &quot;SELECT ShipToAddress1 FROM open_so_inq&quot;)
Set Addr2 = GetTable(Cn, &quot;SELECT ShipToAddress2 FROM open_so_inq&quot;)
Set Filter_Query = GetTable(Cn, &quot;SELECT * FROM open_so_inq&quot;)

%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot;>
<div align=&quot;center&quot;>
<p><img src=&quot;Images/Nomus%20Logo%20.JPG&quot; width=&quot;335&quot; height=&quot;256&quot;> </p>
<form method=&quot;post&quot; action=&quot;&quot;>
<table width=&quot;668&quot; border=&quot;0&quot;>
<tr>
<td>Customer</td>
<td>
<select name=&quot;select&quot;>

<% While (NOT Inquiry_1.EOF) %>
<option value=&quot;<%=Inquiry_1(&quot;Customer&quot;)%>&quot; ><%=Inquiry_1(&quot;Customer&quot;)%></option>
<%
Inquiry_1.MoveNext()
Wend
If (Inquiry_1.CursorType > 0) Then
Inquiry_1.MoveFirst
Else
Inquiry_1.Requery
End If
%>
</select></td>
<td>Ship to Name</td>
<td><input type=&quot;text&quot; name=&quot;textfield2&quot; value=&quot;<%=ShiptoName(&quot;ShipToName&quot;)%>&quot;></td>
<td><input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Filter&quot;></td>
</tr>
<tr>
<td>Ship To Code</td>
<td><select name=&quot;select2&quot;>

<% While (NOT ShipToCode.EOF) %>
<option value=&quot;<%=ShipToCode(&quot;ShipToCode&quot;)%>&quot; ><%=ShipToCode(&quot;ShipToCode&quot;)%></option>
<%
ShipToCode.MoveNext()
Wend
If (ShipToCode.CursorType > 0) Then
ShipToCode.MoveFirst
Else
ShipToCode.Requery
End If
%>
</select></td>
<td>Addr 1</td>
<td><input type=&quot;text&quot; name=&quot;textfield3&quot; value=&quot;<%=Addr1(&quot;ShipToAddress1&quot;)%>&quot;></td>
<td> </td>
</tr>
<tr>
<td>Item Number</td>
<td><select name=&quot;select3&quot;>

<% While (NOT ItemNumber.EOF) %>
<option value=&quot;<%=ItemNumber(&quot;ItemNumber&quot;)%>&quot; ><%=ItemNumber(&quot;ItemNumber&quot;)%></option>
<%
ItemNumber.MoveNext()
Wend
If (ItemNumber.CursorType > 0) Then
ItemNumber.MoveFirst
Else
ItemNumber.Requery
End If
%>
</select></td>
<td>Addr 2</td>
<td><input type=&quot;text&quot; name=&quot;textfield4&quot; value=&quot;<%=Addr2(&quot;ShipToAddress2&quot;)%>&quot;></td>
<td><input type=&quot;submit&quot; name=&quot;Submit4&quot; value=&quot;Exit&quot;></td>
</tr>
<tr>
<td>PO Number</td>
<td><input type=&quot;text&quot; name=&quot;textfield&quot; value=&quot;<%=PONumber(&quot;PONumber&quot;)%>&quot;></td>
<td>City</td>
<td><input type=&quot;text&quot; name=&quot;textfield5&quot; value=&quot;<%=City(&quot;ShipToCity&quot;)%>&quot;></td>
<td></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>State</td>
<td>
<select name=&quot;select4&quot;>
<% While (NOT States.EOF) %>
<option value=&quot;<%=States(&quot;statename&quot;)%>&quot; ><%=States(&quot;statename&quot;)%></option>
<%
States.MoveNext()
Wend
If (States.CursorType > 0) Then
States.MoveFirst
Else
States.Requery
End If
%>
</select></td>
<td> </td>
</tr>
</table>
</form>
<p> </p>
</div>
</body>
</html>
<%
Inquiry_1.Close()
ShipToCode.Close()
ItemNumber.Close()
City.Close()
States.Close()
PONumber.Close()
ShiptoName.Close()
Addr1.Close()
Addr2.Close()
Filter_Query.Close()
%>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top