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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript Client side variables used in server side sql statements HELP

Status
Not open for further replies.

Broozer

Technical User
Jan 5, 2007
4
US
Problem with send a MS Access SQL Query with a client side string variable using VBscript. I use the client side to dim my variable, but when I try using this variable in a sql statement in server side code it fails. I have used msgbox on the client side to debug and I see the statement but the variable is blank or if I use "'" "'" around my variable I get 'variable' and no value of the variable. BUT I can use a number 111 and the sql statment works can somebody help me. THIS HAS GONE ON TOO LONG
COPY OF MY CODE

<Script Language="VBscript">

dim conn2
dim rs2
dim sql
dim v_compID

Document.select.T1.value = "222"
v_compID = Document.select.T1.value


<% Set conn2 = Server.CreateObject("ADODB.Connection") %>
<% conn2.Open "DSN=TimeData" %>
<% Set rs2 = Server.CreateObject("ADODB.Recordset") %>
<% Set rs2.ActiveConnection = conn2 %>

<% sql = "SELECT * FROM Companys WHERE Company ='" & v_compID & "'" %>

<% rs2.Open sql, conn2, 0, 4 %>
msgbox " <%= sql %>"
<% Do while NOT rs2.EOF %>

Document.ComboBox2.AddItem("<%= rs2("Cid") %> " & " " & "<%= rs2("Company") %>")

<% rs2.MoveNext %>
<% Loop %>

<% rs2.close %>
<% conn2.close %>

</SCRIPT>
 
><% sql = "SELECT * FROM Companys WHERE Company ='" & v_compID & "'" %>
[tt]<% sql = "SELECT * FROM Companys WHERE Company ='" & [blue]request("T1")[/blue] & "'" %>[/tt]
Put a conditional on the querying purporting that if trimmed request("T1") is empty, do no query. But, if you think no submit to the same page is performed beforehand for it to perform, then you are out of luck. You have to first submit the page to itself. (And yes, somebody may pronounce the aj-sermon.)
 
Dear tsuji,

How do I go about submiting a page to itself, and then submit it to the next asp page when I am ready to do so ?? HELP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top