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!

data field contents stopping display 1

Status
Not open for further replies.

Cole3c

Technical User
Jul 13, 2005
20
US
Using MS SqlSvr2k DB and ASP to display via web browser.
When the field (data) contains "<full bal", the ASP page stops displaying the data and continues to the next part of the page.
Example data: SETTLED FOR <FULL BAL
Example result: SETTLED FOR
ASP code: <%
if Not objRst.bof And Not objRst.eof Then
dim rs1
set rs1 = server.createObject("ADODB.Recordset")
rs1.ActiveConnection = Application("DBConnString")
rs1.source = "Select * from SpecialResults where OrderID = " & ID
rs1.Open
if not rs1.eof then
rs1.movefirst
%>
<TR><TD valign="top" colspan="2"><FONT FACE="Arial" SIZE=-1><pre><%=rs1("results")%></pre></font></TD></TR>

<%
end if
End If
rs1.close
set rs1 = nothing
%>

How can I trap or bypass this and make the page display the entire field contents?

TIA

Cole
 
DotNetGnat

You have no idea how much you have helped me!

Your <%=Server.HTMLEncode(rs1("results"))%>
worked perfectly.


Thank you very much!

Cole
 
DotNetGnat:

Next similar problem. Clients inputs data containing name such as "O'Connell" and the apostophe causes similar ASP error and stops processing of page.
Sample code: objRst.source = "select * from ordersubjects where 0=1"
objRst.Open
objRst.addNew
objRst("compID") = request.form("CompID")
objRst("daterequested") = Now()
objRst("clientref") = request.form("ref")


Can I use objRst("clientref") = Server.HTMLEncode(request.form("ref"))

Or, suggestion?

TIA
Cole
 
nope...you need replace() function here
try this:

objRst("clientref") = Replace(request.form("ref"),"'","''")

what we are doing here is that we are replacing a single apostrophe with two asptrophe's so that we can suppress the significance of single one...

hope that helps

-DNG
 
I understand that. Thank you.

But that Replace will only fix a problem with apostophes-is there a way to take care of the other problem characters (and what else am i looking for)?

Also. would there be a way to kind of globally do this? I have many different pages scattered in 6 different directories.

You are a great help,

Cole
 
For Apostrophe's and some similar characters Replace() function will work fine...for some weird characters :)
i generally use Server.HTMLEncode()...

You will need to look at the Regex() function(also stands for Regular Expression function) for any validations

and globally you can create a function in a file and include this file on any asp page and use the functions...

for Regular Expressions try this link:

-DNG
 
So...

Can I use
objRst("clientref") = Replace(request.form("ref"),"[^A-Za-z0-9]"," ")
to find any non alphanumeric characters and replace them with a 'space'

Cole
 
My apologies for being thick. I read all of your suggestions and tried several things-none of which will get rid of non-alphanumerics.

This:
objRst("clientref") = Replace(request.form("ref"),"[^a-zA-Z0-9]","_")

and this:
objRst("clientref") = Replace(request.form("ref"),"\W","_")

isn't doing anything.

but this:
objRst("clientref") = Replace(request.form("ref"),"'","_")

is correctly trapping and eliminating the apostophe--and that is a major improvement. I really need to prevent clients from entering non-alphanumerics ('<>.,/\[]! etc...)

Where am I going wrong?

Here is the current block of code:
if (not isNull(Request.Form("LNAME"))) or Request.Form("LNAME")<>"" then
if (len(Request.Form("LNAME"))) > 0 then
if (UCASE(Request.Form("COMPID"))) <> "MAFDL" then
set objRst = server.createobject("ADODB.Recordset")
objRst.ActiveConnection = Application("DBConnString")
objRst.LockType = 2
objRst.CursorType = 1
objRst.source = "select * from ordersubjects where 0=1"
objRst.Open
objRst.addNew
objRst("compID") = request.form("CompID")
objRst("daterequested") = Now()
objRst("clientref") = Replace(request.form("ref"),"'","_")
objRst("fname") = Replace(request.form("fname"),"'","_")
objRst("mname") = Replace(request.form("mname"),"'","_")
objRst("lname") = Replace(request.form("Lname"),"'","_")
objRst("ssn") = request.form("ssn")
objRst("dob") = request.form("dob")
objRst.update

subjectNumber = objRst("SubjectNumber")
objRst.close
set objRst = nothing
else
set objRst = server.Createobject("ADODB.Recordset")
objRst.ActiveConnection = Application("DBConnString")
objRst.source = "select subjectnumber from ordersubjects where compID='" & Request.Form("CompID") _
& "' and clientref = '" & Request.form("ref") & "'"
objRst.Open
if objRst.Eof then
%>

 
take a look at this my other thread...
thread333-1093971

and also take a look at the code posted by AnonGod on how he used regular expressions and applied to his string...

try it out and let us know if you get any errors...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top