|
| |
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: search database with the text file uploaded - 2/3/2006 14:31:33
Sorry if I'm intruding but I've been watching this post a little while and I'm of the opinion like dpf - why bother with an upload. I threw together a quick script that will do what you want by posting a comma separated list of text values in a form and searches for the part and returns prices of each found part. My test page is here: http://www.clarkinsurance.com/54.asp and I have setup a quick Access DB with 4 parts in it: widget,muckaway valve,doohickey, and gadget Try entering any of those values separated by commas (no extra words like "and") and posting the form. It will return prices of those it found in the list. Here is the complete code of this page: <html>
<head>
<title>Untitled</title>
</head>
<body>
<form method="POST" action="54.asp" name="textForm">
<p><input type="hidden" name="posting" value="y"><textarea rows="2" name="productName" cols="20"></textarea><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
<%
SUB CloseAll
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
END SUB
IF request.form("posting") = "y" THEN
Set conntemp = Server.CreateObject("ADODB.Connection")
myDSN="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("/fpdb/testproducts.mdb")
conntemp.Open myDSN
mySQL = "SELECT * FROM tblProducts WHERE"
IF trim(Request.form("productName")&"") > "" THEN
myTempString = ""
myTempArray = split(trim(Request.form("productName")&""),",")
FOR i = 0 TO ubound(myTempArray)
myTempString = myTempString & "(productName = '" & trim(myTempArray(i)&"") & "') OR "
NEXT
myTempString = left(myTempString,len(myTempString)-4)
ELSE 'if they did not select or paste anything in
myTempString = "(productName='QQQ')"
END IF
mySQL = mySQL & myTempString
set rstemp=conntemp.execute(mySQL)
IF rstemp.eof THEN
Call CloseAll
response.write "No records matched<br>"
response.write "<br>Please try again."
'response.end
ELSE
alldata = rstemp.getrows
Response.write("<table>" & VbCrLf)
FOR i = 0 TO ubound(alldata,2)
Response.write("<tr><td>" & alldata(1,i) & "</td><td>" & alldata(2,i) & "</td></tr>" & VbCrLf)
NEXT
Response.write("</table>" & VbCrLf)
END IF
END IF
%>
</body>
</html> and the DB is a simple Access table with 3 fields: productID (PK autonumber), productName (text field), productPrice (double). That any easier?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
karthik
Posts: 41 Joined: 8/16/2005 Status: offline
|
RE: search database with the text file uploaded - 2/8/2006 1:47:27
Thanks everyone. itz workin great
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|