Selecting records based on Server Variable Paramet

Results 1 to 4 of 4

Thread: Selecting records based on Server Variable Paramet

  1. #1
    Join Date
    Dec 1969
    Posts
    3

    Default Selecting records based on Server Variable Paramet

    Worked on this all day and am close. I am trying to take the user&#039s IP address and translate that to key value (tblLabID)in an Access table that needs to be passed to other asp pages to reference data base based on tblValue. All I am able to use is the IP address. My client does not want users to login using the key value (tblLabID). This is what I have:<BR><BR>Session("strIP") = Request.ServerVariables("REMOTE_ADDR")<BR>myIP = Session("strIP")<BR> <BR>sDBName = "driver={Microsoft Access Driver (*.mdb)};dbq=C:My DocumentsISDB.mdb"<BR>Set objDB = Server.CreateObject("ADODB.Connection")<BR>objDB.O pen sDBName<BR><BR>set objRS = objDB.Execute ("Select LabTable.tblLabID as myID, from LabTable where (LabTable.tblLabIP = &#039myIP&#039)")<BR><BR>I have put all kinds of checks so that I know:<BR> 1) I am picking up the correct IP address<BR> 2) If I eliminate the where clause, I get the information I<BR> need passed correctly.<BR> 3) If I hard code where LabTable.tblLabIP = &#039 xxx.x.xxx.x&#039 I<BR> get the information I need passed correctly.<BR> 4) I looked at myIP and it has the correct IP address.<BR><BR><BR>I can see that the problem is comparing the table field with a parameter. I OBVIOUSLY do not know how to do that! HELP PLEASE!<BR><BR>So close, but that does not me get there!<BR><BR>

  2. #2
    Nathen Grass Guest

    Default RE: Selecting records based on Server Variable Par

    Your SQL statement has the string "myIP" hardcoded into it. The SQL string should be:<BR><BR>("Select LabTable.tblLabID as myID, from LabTable where (LabTable.tblLabIP = &#039" & myIP & "&#039)"

  3. #3
    Join Date
    Dec 1969
    Posts
    3

    Default RE: Selecting records based on Server Variable Par

    This is what I changed it to, but do not get a match?<BR><BR>set objRS = objDB.Execute ("Select LabTable.tblLabID as myID, LabTable.tblLabState as myState from LabTable where (LabTable.tblLabID = &#039"& myIP &"&#039)")<BR>

  4. #4
    Nathen Grass Guest

    Default RE: Selecting records based on Server Variable Par

    Hmm... I figured that would have worked. The only thing I can suggest is to write the SQL statment generated and copy and paste it into the database you&#039re using and run it.<BR><BR>i.e.<BR>&#060;%<BR>SQL = "Select LabTable.tblLabID as myID,"<BR>SQL = SQL & " LabTable.tblLabState as myState"<BR>SQL = SQL & " from LabTable"<BR>SQL = SQL & " where (LabTable.tblLabID = &#039" & myIP & "&#039)"<BR>response.write(SQL)<BR>&#039More code here<BR>%&#062;<BR><BR>This way you&#039ll know you have the exact SQL statment that is trying to be run.<BR>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •