﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Issues  » Single quotes in a string cause errors</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 08 Sep 2026 21:17:26 GMT</lastBuildDate><ttl>20</ttl><item><title>Single quotes in a string cause errors</title><link>http://forum.strataframe.net/FindPost2016.aspx</link><description>I have some string fields on a few of my forms that have apostrophes (single quotes) in them in the database.&amp;nbsp; Things like New Year's Day cause errors when I go to save the BO using the Save method.&amp;nbsp; How do I get around this?</description><pubDate>Mon, 31 Jul 2006 13:21:46 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item><item><title>RE: Single quotes in a string cause errors</title><link>http://forum.strataframe.net/FindPost2021.aspx</link><description>Hehe, that's not a problem.&amp;nbsp; If you have any problems on the save, just post that debug output along with the post, and it will help us solve the problem much faster.&lt;/P&gt;&lt;P&gt;If you ever need to send values to the server (especially string values, since they can contain single quotes), don't concatenate a bunch of strings together into the whole command; parameterize the command instead.&amp;nbsp; Parameterizing commands also helps SQL Server to cache the execution path of the command for future executions since the command text itself doesn't change, just the values of the parameters.&lt;/P&gt;&lt;P&gt;So, instead of this:&lt;/P&gt;&lt;P&gt;Me.FillDataTable("SELECT * FROM MyTable WHERE MyField = '" &amp;amp; SomeValue &amp;amp; "'")&lt;/P&gt;&lt;P&gt;Do this:&lt;/P&gt;&lt;P&gt;Dim loCommand As New SqlCommand()&lt;BR&gt;loCommand.CommandText = "SELECT * FROM MyTable WHERE MyField = @MyValue"&lt;BR&gt;loCommand.Parameters.Add("@MyValue", SqlDbType.NVarChar)&lt;BR&gt;loCommand.Parameters("@MyValue").Value = MyValue&lt;BR&gt;Me.FillDataTable(loCommand)&lt;/P&gt;&lt;P&gt;You'll notice that you can pass a DbCommand object to the data source for execution (which is your SqlCommand object).&amp;nbsp; Have fun :)</description><pubDate>Mon, 31 Jul 2006 13:21:46 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Single quotes in a string cause errors</title><link>http://forum.strataframe.net/FindPost2020.aspx</link><description>Sorry about this one...I think it's my mistake in a SQL statement I didn't realize it was hitting.</description><pubDate>Mon, 31 Jul 2006 13:16:20 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item><item><title>RE: Single quotes in a string cause errors</title><link>http://forum.strataframe.net/FindPost2019.aspx</link><description>When you run your application, in your SetDataSources() method of the AppMain.vb file, after the call to ConnectionManager.SetConnections(), add this line:&lt;/P&gt;&lt;P&gt;MicroFour.StrataFrame.DataLayer.DataSources("").SetDebugOn("C:\SFDebug.html", True)&lt;/P&gt;&lt;P&gt;When you run your app, and try to save, it will record the debug results to that output file.&amp;nbsp; Then, if you can attatch the file to a forum post, it will tell me the syntax of the command that it's trying to execute and should help me figure out what's going on.&amp;nbsp; Thanks.</description><pubDate>Mon, 31 Jul 2006 13:10:54 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Single quotes in a string cause errors</title><link>http://forum.strataframe.net/FindPost2018.aspx</link><description>I get "An error occurred while saving data to the server" when I try to save.&lt;/P&gt;&lt;P&gt;I also sometimes get:&lt;BR&gt;Line 1: Incorrect syntax near 's'.&lt;BR&gt;Unclosed quotation mark before the character string ''.</description><pubDate>Mon, 31 Jul 2006 13:06:51 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item><item><title>RE: Single quotes in a string cause errors</title><link>http://forum.strataframe.net/FindPost2017.aspx</link><description>What is the error message you're receiving?&amp;nbsp; All of the saves are parameterized, so having apostrophes within your values shouldn't matter.&amp;nbsp; We use apostrophes and special characters in our field values all the time.&amp;nbsp; If you can post the exception and any inner exceptions (or just the output from the red error window), that should be enough.</description><pubDate>Mon, 31 Jul 2006 12:56:50 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>