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

MsgBoards and access DB, but error with appotrophies in sql statement? 1

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
US
Hello,
As you all know, we type in messages for the message boards here and when we hit enter to the next line, the next line will be printed on the viewing board...or appostrophe's entered will show up without problems/errors.


Question:

Does anyone know how to make the returns/enters show in the display, and how to make it work even when the user uses appostrophe's...not to make the appostrophe's disappear, I still want them there...just don't want the error.


My Problem:

I created a message board for my site using the memo option in Access as the data type holder for the message that is left. However when a person will hit enter, it won't show the returns in the display. If they entered an appostrophe, then there is an error because the appostrophe conflicted with the sql statement and it won't get processed.


Example:

-----------page1.asp-------------
<form action='page2.asp' method='post'>
<textarea name='msg' width='30' height='20'></textarea>
<input type='submit' value='Submit'><input type='reset' value='Reset'>
</form>

-----------page2.asp-------------
<%
dim sql, message
message = request.form(&quot;msg&quot;)
sql = &quot;INSERT INTO tbl_msgboard SET tbl_msgboard.message='&quot; & message & &quot;';&quot;
' If syntax is wrong, is because I'm writing
' off the top of my head right now...think it's
' correct though

set conn = server.createobject(&quot;ADODB.Connection&quot;)
DSNtemp = &quot;connection&quot;
conn.Open DSNtemp
set rs = server.createobject(&quot;ADODB.Recordset&quot;)
rs.Open sql, conn, 3, 3
conn.close
Set conn = nothing

response.redirect(&quot;pageView.asp&quot;)
%>

===================================
Now if there was an appostrophe entered in the message by the user, then this wouldn't finish and there would be an error.


Thank you for your time, and effort in advance!!

-Ovatvvon
 
Perfect. That works. Thank you.

Now, do you know how to make the &quot;Enter&quot; button stay? like here, I hit enter...

And it shows it. for me to get that to show on my message board when I'm displaying the memo field, the person would have had to have typed <br>. Do you know how to make it show the next lines automatically like it does for here on tek-tips boards?

-Ovatvvon
 
I found it...YEAH!

to make the carriage-returns (Enter/Return) show in the view area instead of haveing the text continue on the same line, use the replace code with the CrLf (carriage-return, line-feed) substitute.


Example:

strText = Replace(strText, vbCrLf, &quot;<BR>&quot;)

Hope this helps anyone else that was wondering the same thing as me.

later,
-Ovatvvon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top