...

View Full Version : Help with sql statement



charlieb
09-03-2004, 05:31 AM
I get this message when I try to run my code:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'pj'.

/projectors/Test2.asp, line 19


Here is the code:


<%
Response.Buffer = True

' projector to retrieve
Dim pj
pj = Request("ProjectorList")


' Connection String
Dim connStr
connStr = "dsn=myyrroad;uid=c5558;pwd=7688900;network=dbmssocn"

' Recordset Object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")

' opening connection
rs.Open "select * from screenshots where ProjectorName = pj", connStr, 3, 4


%>
<html>


<body>
<%
t = rs("Screen")
Response.Write("t")
rs.Close
Set rs = Nothing
Set connStr = Nothing
%>
</body>

</html>



I would appreciate any help

glenngv
09-03-2004, 06:29 AM
rs.Open "select * from screenshots where ProjectorName = '" & replace(pj,"'","''") & "'", connStr, 3, 4

See the sticky post regarding escaping single quotes.

charlieb
09-03-2004, 07:14 AM
Glen, Thanks a million :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum