Guest_imported
New member
- Jan 1, 1970
- 0
I'm new to ASP and I'm trying my hands on Database. Can you please help me out with the following.
I have a table with two fields Order Number and Item. And the data in the table will be like:
OrderNumber Item
---------- ----
A001 Mouse
A001 Modem
A002 Monitor
A003 Speaker
What I would like to know is how can I code an ASP page where the Order Number A001, which is repeated twice, will be treated as the same Order Number. And it will show the following result based on a search form.
The Order Number A001 has Mouse, Modem
Instead of:
The Order Number A001 has Mouse
The Order Number A001 has Modem
I'm able to code but I cannot make my code understand both A001 is the same Order Number. My code takes them as different Order Numbers.
Any Help regarding this problem will be highly appreciated. Thanks in advance. Waiting eagerly for your reply.
Best regards,
Soumya Shankar Ghosal
ssghosal@caltiger.com
The code I tried is as follows: -
----------------------------------
<%@ Language=VBSCRIPT %>
<% Option Explicit %>
<!--include virtual="/adovbs.inc"-->
<%
'Creating a connection to the Access database
Dim objConnection
Set objConnection = Server.CreateObject("ADODB.Connection"
objConnection.ConnectionString = "DSN=My.dsn"
objConnection.Open
Dim strSQL
strSQL = "SELECT * FROM OrderInfo WHERE OrderNo='A001'"
'Creating a recordset object instance and executing the SQL statement
Dim objRecordset
Set objRecordset = server.CreateObject("ADODB.Recordset"
objRecordset.Open strSQL, objConnection
'Trapping a Recordset field in a variable tmp
Dim tmp
objRecordset.MoveFirst
tmp = objRecordset.Fields("OrderNo" & "<P>"
Response.Write "The number is : "
Response.Write tmp
If objRecordset.EOF Then
'No records were returned
Response.Write "No matches found based on your Search"
Else
Do While Not objRecordset.EOF
'If (StrComp(objRecordset("OrderNo", tmp, vbTextCompare)=1) Then
Response.Write objRecordset("OrderNo" & "<BR>"
Response.Write objRecordset("Item" & "<BR>"
Response.Write "<P>"
'objRecordset.MoveNext
'tmp = objRecordset.Fields("OrderNo"
'End If
objRecordset.MoveNext
'tmp = objRecordset.Fields("OrderNo"
Loop
End If
objRecordset.Close
Set objRecordset = Nothing
objConnection.Close
Set objConnection = Nothing
%>
I have a table with two fields Order Number and Item. And the data in the table will be like:
OrderNumber Item
---------- ----
A001 Mouse
A001 Modem
A002 Monitor
A003 Speaker
What I would like to know is how can I code an ASP page where the Order Number A001, which is repeated twice, will be treated as the same Order Number. And it will show the following result based on a search form.
The Order Number A001 has Mouse, Modem
Instead of:
The Order Number A001 has Mouse
The Order Number A001 has Modem
I'm able to code but I cannot make my code understand both A001 is the same Order Number. My code takes them as different Order Numbers.
Any Help regarding this problem will be highly appreciated. Thanks in advance. Waiting eagerly for your reply.
Best regards,
Soumya Shankar Ghosal
ssghosal@caltiger.com
The code I tried is as follows: -
----------------------------------
<%@ Language=VBSCRIPT %>
<% Option Explicit %>
<!--include virtual="/adovbs.inc"-->
<%
'Creating a connection to the Access database
Dim objConnection
Set objConnection = Server.CreateObject("ADODB.Connection"
objConnection.ConnectionString = "DSN=My.dsn"
objConnection.Open
Dim strSQL
strSQL = "SELECT * FROM OrderInfo WHERE OrderNo='A001'"
'Creating a recordset object instance and executing the SQL statement
Dim objRecordset
Set objRecordset = server.CreateObject("ADODB.Recordset"
objRecordset.Open strSQL, objConnection
'Trapping a Recordset field in a variable tmp
Dim tmp
objRecordset.MoveFirst
tmp = objRecordset.Fields("OrderNo" & "<P>"
Response.Write "The number is : "
Response.Write tmp
If objRecordset.EOF Then
'No records were returned
Response.Write "No matches found based on your Search"
Else
Do While Not objRecordset.EOF
'If (StrComp(objRecordset("OrderNo", tmp, vbTextCompare)=1) Then
Response.Write objRecordset("OrderNo" & "<BR>"
Response.Write objRecordset("Item" & "<BR>"
Response.Write "<P>"
'objRecordset.MoveNext
'tmp = objRecordset.Fields("OrderNo"
'End If
objRecordset.MoveNext
'tmp = objRecordset.Fields("OrderNo"
Loop
End If
objRecordset.Close
Set objRecordset = Nothing
objConnection.Close
Set objConnection = Nothing
%>