Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How do I pass a % sign to SQL Server from an ASP page?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-04 : 11:18:47
Phillip writes "When I run the following query from SQL ServerQuery Analyzer:

select ppl_part.part_number, ppl_part.description, ppl_part.value, brp_part.inv_qty
FROM PPL_PART LEFT OUTER JOIN BRP_PART ON PPL_PART.part_number = BRP_PART.PARTNO
where ppl_part.pgroup = 'Passive'
and ppl_part.family = 'Resistor'
and ppl_part.member = 'Fixed Film'
and ppl_part.description = 'RES FILM 1.62K 1% .05W'
and ppl_part.usage in ('P','S','U')
order by 1

It returns 2 rows properly.

When I build it through an ASP Page (below), I get NO RECORDS FOUND:

'Build SQL string to select records to be displayed to the user
strSql = "SELECT "
For ctr = 0 to headercnt
if ctr <> headercnt Then
strSql = strSql & saveHeadRS(1,ctr) & "." & saveHeadRS(2,ctr) & ", "
'Response.Write("
" & strSql)
else
strSql = strSql & saveHeadRS(1,ctr) & "." & saveHeadRS(2,ctr) & " "
'Get all records from PPL_PART whether there is a match in BRP_PART or not
strSql = strSql & "FROM PPL_PART LEFT OUTER JOIN BRP_PART ON PPL_PART.part_number = BRP_PART.PARTNO "
strSql = strSql & "WHERE (PPL_PART.pgroup = '" & Request.QueryString("pgroup") & "') "
strSql = strSql & "AND (PPL_PART.family = '" & Request.QueryString("family") & "') "
strSql = strSql & "AND (PPL_PART.member = '" & Request.QueryString("member") & "') "
strSql = strSql & "AND (PPL_PART." & Request.QueryString("viewtype") & " = '" & Request.QueryString("viewvalue") & "') "
'getCookie("selectcriteria") here, cookie is set in header checkbox
strSql = strSql & Request.Cookies("selectcriteria")
strSql = strSql & "ORDER BY " & Request.QueryString("sort")
'Response.Write("
" & strSql)
end if
Next

'Open Connection object and pass SQLstring into it
set objConn = server.CreateObject("adodb.connection")
objConn.Open myDSN
set objRS = objConn.Execute(strSql)


IT CRASHES AND BURNS ON THE PERCENT SIGN. Any suggestions?

Thank you, Phil"
   

- Advertisement -