ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 13th, 2000, 01:04 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Database Question

<i><b>Originally posted by : Kammi (ksj_99@hotmail.com)</b></i><br /><br />Hi,<br />the code to search for example an item from a big database <br />which would result in retrieving the values concerned to the person who has logged in to the site and the items of other users in <br />the database would be hidden to him.<br /><br /><br />Im trying to use the following code <br /><br />Thanks<br />Kammi<br /><br /><!-- #INCLUDE FILE="adovbs.inc" --><br /><!-- #INCLUDE FILE="DataStore.inc" --><br /><!-- #INCLUDE FILE="RecToTable.asp" --><br /><br /><HEAD><br /><TITLE>Find Contacts</TITLE><br /></HEAD><br /><BODY><br /><br /><%<br /> Dim strSQL ' SQL String<br /> Dim objRec ' Recordset object<br /> Dim objField ' Field object<br /> Dim intCount ' number of fields selected<br /> Dim vbQuote ' quote character<br /> Dim vbCR ' carriage return<br />'strUserName= Request.QueryString("mfrnm")<br />'strUserName = Request.Form("UserName")<br /><br /><br />'strPassword = Request.Form("Password")<br />'strUserName= Request.QueryString("ManufacturerName")<br />'strUserName= "a"<br />'strManufacturerName=Request.QueryString("ManufacturerName")<br />'strManufacturerName=Request.QueryString("ManufacturerName")<br /><br />strUserName=session("UserName")<br /><br /><br /><br />Response.Write session("UserName")<br /> ' set the constants<br /> vbQuote = Chr(34)<br /> vbCR = Chr(13)<br /><br /> ' check whether we have selected a state or not<br /> If Request.Form("Field").Count > 0 Then<br /><br /> ' we have a state, therefore show contacts for selected state<br /><br /> ' find out which fields are to be selected<br /> strSQL = ""<br /> For intCount = 1 to Request.Form("Field").Count<br /> strSQL = strSQL & Request.Form("Field")(intCount) & ", "<br /> Next<br /><br /> ' strip off the trailing comma and space added in the loop<br /> strSQL = Left(strSQL, Len(strSQL) - 2)<br /><br /> 'strSQL = "SELECT " & strSQL & " FROM Furniture"<br /> strSQL="SELECT * FROM Manufacturer,Furniture "<br /><br /> 'strSQL1="SELECT <br /> <br /> <br /> strSQL="SELECT * FROM Manufacturer,Furniture WHERE (Manufacturer.ManufacturerName=Furniture.Manufactu rer) AND Manufacturer.LoginID='" & session("UserName") &"'"<br />'Response.Write ("SELECT * FROM Manufacturer,Furniture WHERE Manufacturer.ManufacturerName=Furniture.Manufactur er AND Manufacturer.LoginID='"& strUserName &"'")<br /><br />'strQuery=strQuery & "ORDER BY Number"<br />'Set objRS=objConn.Execute("SELECT * FROM Manufacturer WHERE LoginID='"& strUserName &"'" )<br />'Set objRS=objConn.Execute("SELECT * FROM Manufacturer,Furniture WHERE Manufacturer.ManufacturerName=Furniture.Manufactur er AND Manufacturer.LoginID='"& strUserName &"'")<br /><br /><br /><br /><br /><br /><br /><br /> ' only add a where clause if they requested a state<br /> If Request.Form("Piece") <> "" Then<br /> strSQL = strSQL & " AND Piece = '" & Request.Form("Piece") & "'"<br /> End If<br />'Response.Write strSQL<br /> ' create the recordset<br /> Set objRec = Server.CreateObject ("ADODB.Recordset")<br /><br /> objRec.Open strSQL, strConnect, adOpenForwardOnly, _<br /> adLockReadOnly, adCmdText<br /><br /> ' write a table of the recordset<br /> Response.Write RecToTable (objRec)<br /><br /> ' clean up<br /> objRec.Close<br /> Set objRec = Nothing<br />%><br /><br /><% Else %><br /><br /><FORM NAME=ContactInfo ACTION="PContactsInFurn2.asp" METHOD="POST"><br /><H2>Find Contacts of Manufacturer</H2><br />Enter the Furniture Item to find:<br /><INPUT TYPE=TEXT NAME="Piece"><br /><P><br />Please select which fields you would like:<P><br /><%<br /> ' no checkboxes exist, therefore create them<br /><br /> ' create a recordset on the Contacts<br /> 'strUserName= Request.QueryString("mfrnm")<br /> Set objRec = Server.CreateObject ("ADODB.Recordset")<br /><br /> objRec.Open "Furniture", strConnect, adOpenForwardOnly, _<br /> adLockReadOnly, adCmdTable<br /><br /> ' create a checkbox in the form for each field in the recordset<br /> For Each objField in objRec.Fields<br /> Response.Write "<INPUT TYPE=CHECKBOX CHECKED NAME=" & _<br /> vbQuot & "Field" & vbQuot & _<br /> " VALUE=" & _<br /> vbQuot & objField.Name & vbQuot & _<br /> ">" & objField.Name & "<BR>" & vbCR<br /> Next<br /><br /> ' clean up<br /> objRec.Close<br /> Set objRec = Nothing<br />%><br /><br /><INPUT TYPE=SUBMIT VALUE="Find" id=SUBMIT1 name=SUBMIT1><br /><INPUT TYPE=RESET VALUE="Clear" id=RESET1 name=RESET1><br /></FORM><br /><br /><%<br /> End If<br /> <br />%><br /><br /></BODY><br /></HTML><br /><br /><br /><br /><br /><br /><br /><br />

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Database Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway