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

String Variants

Status
Not open for further replies.

boab

Programmer
May 30, 2001
75
GB
Hi can anybody explain how to initialise a string variant as I am trying to use a string 'sql' in a creating a recordset object the server is just throwing back this error msg

Object required: '[string: "SELECT*FROM Messages"]'

I am running PWS4 could this be a reason?
 
You need to build up the entire string for the SQL statement including any variables and then execute the command.

If you post the whole code some one else may be able to help more. I dont want to go to Chelsea!!!
 
Here is the complete code for the page please help this is driving me nuts!X-)




<%@ language=VBScript%>
<%
dim con, rst, sql, msgId
dim recip



set user = request.QueryString(&quot;user&quot;)

set con=Server.CreateObject(&quot;ADODB.Connection&quot;)
Call con.Open(&quot;COED_DSN&quot;, &quot;BoabFett&quot;, &quot;noddy1&quot;)
set sql =&quot;SELECT*FROM Messages WHERE Recipient=public&quot;
set rst=Server.CreateObject(&quot;ADODB.Recordset&quot;)
Call rst.Open(sql, con)

set msgId=rst(&quot;MessageId&quot;)

Call rst.Close()
set rst=Nothing


Function viewMsg(val)
set sql = String(&quot;SELECT * FROM Messages WHERE MessageID=&quot;& val)
set rst = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Call rst.Open(sql, con)

return rst(&quot;MessageTxt&quot;)
End Function
%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>

<style>
tr.DataInfo{backgroundcolor;aliceblue;color:cyan}
</style>
<script language=javascript>
<!--
function viewMsg(val) {
var w =window.open(width=400, height=350, status=no,resizable=no);
w.document.write(&quot;<textarea cols=50 value=&quot;+&quot;+val+&quot;&quot;></textarea>&quot;)
w.document.write(&quot;<input type=&quot;+&quot;+&quot;button&quot;+&quot;+&quot; Value=&quot;+&quot;+&quot;Close&quot;+&quot;+&quot; onClick=&quot;+&quot;+&quot;javascript:window.close()&quot;+&quot;+&quot;>&quot;);
}
-->
</script>

</head>

<body bgcolor=&quot;#000066&quot; text=&quot;#00FFFF&quot; background=&quot;../1163k5Edinburgh.gif&quot; link=&quot;#00FFFF&quot; vlink=&quot;#00FFFF&quot; alink=&quot;#00FFFF&quot;>
<div align=&quot;center&quot;>
<p><font size=&quot;7&quot;><i>C</i></font><font size=&quot;5&quot;>ity of <font size=&quot;7&quot;><i>E</i></font>dinburgh
<font size=&quot;7&quot;><i>P</i></font>ipes & <font size=&quot;7&quot;><i>D</i></font>rums</font></p>
<p><font size=&quot;5&quot;><i><font size=&quot;7&quot;>P</font></i>ublic <font size=&quot;7&quot;><i>M</i></font>essage
<font size=&quot;7&quot;><i>B</i></font>oard</font></p>
<p> </p>
</div>

<div align=&quot;center&quot;>
<table>
<tr style=fontfamily:verdana;backgroundcolor:aliceblue;color:cyan>
<td>Message Subject</td>
<td>Sender</td>
<td>Date/Time sent</td>
<td>View Message Text</td>
</tr>
<%
While(rst.EOF=false)
Response.Write(&quot;<tr class=DataInfo>&quot;&vbCrLf)
Response.Write(&quot;<td>&quot;& rst(&quot;msgSubj&quot;)&&quot;</td>&quot;&vbCrLf)
Response.Write(&quot;<td>&quot;& rst(&quot;Sender&quot;)&&quot;</td>&quot;&vbCrLf)
Response.Write(&quot;<td>&quot;& rst(&quot;DateTime&quot;)&&quot;</td>&quot;&vbCrLf)
Response.Write(&quot;<td><input type =&quot;&quot; &&quot;button&quot;&quot; &&quot;value=&quot;&quot; &&quot;View Message&quot;&quot; &&quot;onClick=&quot;&quot; &&quot;viewMsg(msgId)&quot;&quot; &&quot;></td>&quot;&vbCrLf)
Response.Write(&quot;</tr>&quot;&vbCrLf)
Wend
%>
</table>
</div>
</body>
</html>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top