DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sat, 11 Aug 2007 12:02:02 -0400,    posted on: microsoft.public.dotnet.framework.adonet        back       

Thread Index
  1    Carl Thomas
          2    Kerry Moorman
          3    Morten Wennevik
          4    Carl Thomas
          5    Carl Thomas
                 6    Morten Wennevik [C# MVP]
                 7    Carl Thomas
          8    Kerry Moorman
          9    Carl Thomas
          10    Tom Garth
          11    Carl Thomas
          12    William Vaughn
                 13    Carl Thomas
          14    William Vaughn


Data with Apostrophes   
I have names in a data collection the include apostrophes like O'Hare.  When 
I use a simple VC#/ADO.NET approach with an SQL INSERT statement and 
cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that there 
is an unterminated string.   When I try using a DataAdapter and 
SqlCommandBuilder, it says I need and INSERT statement, although it will do 
data without the apostrophes.   Any idea how to handle these cases?  I've 
also tried parameters, but the results are the same.

TIA

Carl
Date:Sat, 11 Aug 2007 12:02:02 -0400   Author:  

RE: Data with Apostrophes   
Carl,

Can you post your code where you use cmd.ExecuteNonQuery with parameters and 
you still have problems?

Kerry Moorman


"Carl Thomas" wrote:


> I have names in a data collection the include apostrophes like O'Hare.  When 
> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and 
> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that there 
> is an unterminated string.   When I try using a DataAdapter and 
> SqlCommandBuilder, it says I need and INSERT statement, although it will do 
> data without the apostrophes.   Any idea how to handle these cases?  I've 
> also tried parameters, but the results are the same.
> 
> TIA
> 
> Carl
> 
> 
> 
Date:Sat, 11 Aug 2007 10:08:00 -0700   Author:  

Re: Data with Apostrophes   
On Sat, 11 Aug 2007 18:02:02 +0200, Carl Thomas  wrote:


> I have names in a data collection the include apostrophes like O'Hare.  When
> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that there
> is an unterminated string.   When I try using a DataAdapter and
> SqlCommandBuilder, it says I need and INSERT statement, although it will do
> data without the apostrophes.   Any idea how to handle these cases?  I've
> also tried parameters, but the results are the same.
>
> TIA
>
> Carl
>
>
>


Carl, use SqlParameter to pass the data.  Saves you all these kinds of troubles.

-- 
Happy coding!
Morten Wennevik [C# MVP]
Date:Sat, 11 Aug 2007 20:03:39 +0200   Author:  

Re: Data with Apostrophes   
The problem occurs at runtime from the following code snippet:

                                            using (SqlDataReader drdr = 
cmdIn.ExecuteReader())
                                            {
                                                drdr.Read();
                                                string latitude = 
GetCoordinateString( drdr.GetString( 1 ) );
                                                string longitude = 
GetCoordinateString( drdr.GetString( 2 ) );
                                                string strInsertString
                                                         = "INSERT INTO 
AirportData (ICAO, Latitude, Longitude, Altitude,"
                                                                             
        + " AirportName, CityName,"
                                                                             
        + " StateProvinceName, CountryName)"
                                                         + "VALUES ('" + 
drdr.GetString( 0 ) + "', '"
                                                                       + 
latitude + " ', '"
                                                                       + 
longitude + " ', '"
                                                                       + 
drdr.GetString( 3 ) + "', '"
                                                                       + 
drdr.GetString( 4 ) + "', '"
                                                                       + 
drdr.GetString( 5 ) + "', '"
                                                                       + 
drdr.GetString( 6 ) + "', '"
                                                                       + 
drdr.GetString( 7 ) + "')";
                                                using (SqlCommand cmdInsert 
= new SqlCommand( strInsertString, cnOut ))
                                                {
                                                    cmdInsert.ExecuteNonQuery();
                                                }
                                            }
When it hits O'Hare as once instance, it does an SqlException at 
ExecuteNonQuery claiming that there is an unterminated string.  I have since 
found a way around it that blythly ignores the problem.  I've broken the 
problem up to retrieve the data from one database using an SqlDataReader and 
out it into a class list and then separately reading it from a class list 
into an SqlDataAdapter for the insert.  It is a little less elegent, but 
works without a problem.

Carl

"Kerry Moorman"  wrote in message 
news:BB72B829-BA04-4BA8-8E3D-04E1EBBB528C@microsoft.com...

> Carl,
>
> Can you post your code where you use cmd.ExecuteNonQuery with parameters 
> and
> you still have problems?
>
> Kerry Moorman
>
>
> "Carl Thomas" wrote:
>
>> I have names in a data collection the include apostrophes like O'Hare. 
>> When
>> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
>> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that 
>> there
>> is an unterminated string.   When I try using a DataAdapter and
>> SqlCommandBuilder, it says I need and INSERT statement, although it will 
>> do
>> data without the apostrophes.   Any idea how to handle these cases?  I've
>> also tried parameters, but the results are the same.
>>
>> TIA
>>
>> Carl
>>
>>
>> 
Date:Sun, 12 Aug 2007 17:10:00 -0400   Author:  

Re: Data with Apostrophes   
I haven't tried SqlParameters since I found a work around.  I may give it a 
try since my solution was less elegent than I'd like (see my reply to Kerry 
Moorman's post).  Somehow, I've never gotten around to SqlParameters, but it 
might be a nice application to try.

Thanx.

Carl

"Morten Wennevik"  wrote in message 
news:op.twwpsdsdklbvpo@ubuan...

> On Sat, 11 Aug 2007 18:02:02 +0200, Carl Thomas 
>  wrote:
>
>> I have names in a data collection the include apostrophes like O'Hare. 
>> When
>> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
>> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that 
>> there
>> is an unterminated string.   When I try using a DataAdapter and
>> SqlCommandBuilder, it says I need and INSERT statement, although it will 
>> do
>> data without the apostrophes.   Any idea how to handle these cases?  I've
>> also tried parameters, but the results are the same.
>>
>> TIA
>>
>> Carl
>>
>>
>>
>
> Carl, use SqlParameter to pass the data.  Saves you all these kinds of 
> troubles.
>
> -- 
> Happy coding!
> Morten Wennevik [C# MVP] 
Date:Sun, 12 Aug 2007 17:13:11 -0400   Author:  

Re: Data with Apostrophes   
Carl,

I don't see any use of parameters, as you mentioned in your first post.

Kerry Moorman


"Carl Thomas" wrote:


> The problem occurs at runtime from the following code snippet:
> 
>                                             using (SqlDataReader drdr = 
> cmdIn.ExecuteReader())
>                                             {
>                                                 drdr.Read();
>                                                 string latitude = 
> GetCoordinateString( drdr.GetString( 1 ) );
>                                                 string longitude = 
> GetCoordinateString( drdr.GetString( 2 ) );
>                                                 string strInsertString
>                                                          = "INSERT INTO 
> AirportData (ICAO, Latitude, Longitude, Altitude,"
>                                                                              
>         + " AirportName, CityName,"
>                                                                              
>         + " StateProvinceName, CountryName)"
>                                                          + "VALUES ('" + 
> drdr.GetString( 0 ) + "', '"
>                                                                        + 
> latitude + " ', '"
>                                                                        + 
> longitude + " ', '"
>                                                                        + 
> drdr.GetString( 3 ) + "', '"
>                                                                        + 
> drdr.GetString( 4 ) + "', '"
>                                                                        + 
> drdr.GetString( 5 ) + "', '"
>                                                                        + 
> drdr.GetString( 6 ) + "', '"
>                                                                        + 
> drdr.GetString( 7 ) + "')";
>                                                 using (SqlCommand cmdInsert 
> = new SqlCommand( strInsertString, cnOut ))
>                                                 {
>                                                     cmdInsert.ExecuteNonQuery();
>                                                 }
>                                             }
> When it hits O'Hare as once instance, it does an SqlException at 
> ExecuteNonQuery claiming that there is an unterminated string.  I have since 
> found a way around it that blythly ignores the problem.  I've broken the 
> problem up to retrieve the data from one database using an SqlDataReader and 
> out it into a class list and then separately reading it from a class list 
> into an SqlDataAdapter for the insert.  It is a little less elegent, but 
> works without a problem.
> 
> Carl
> 
> "Kerry Moorman"  wrote in message 
> news:BB72B829-BA04-4BA8-8E3D-04E1EBBB528C@microsoft.com...
> > Carl,
> >
> > Can you post your code where you use cmd.ExecuteNonQuery with parameters 
> > and
> > you still have problems?
> >
> > Kerry Moorman
> >
> >
> > "Carl Thomas" wrote:
> >
> >> I have names in a data collection the include apostrophes like O'Hare. 
> >> When
> >> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
> >> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that 
> >> there
> >> is an unterminated string.   When I try using a DataAdapter and
> >> SqlCommandBuilder, it says I need and INSERT statement, although it will 
> >> do
> >> data without the apostrophes.   Any idea how to handle these cases?  I've
> >> also tried parameters, but the results are the same.
> >>
> >> TIA
> >>
> >> Carl
> >>
> >>
> >> 
> 
> 
> 
Date:Sun, 12 Aug 2007 15:10:00 -0700   Author:  

Re: Data with Apostrophes   
On Sun, 12 Aug 2007 23:13:11 +0200, Carl Thomas  wrote:


> I haven't tried SqlParameters since I found a work around.  I may give it a
> try since my solution was less elegent than I'd like (see my reply to Kerry
> Moorman's post).  Somehow, I've never gotten around to SqlParameters, but it
> might be a nice application to try.
>
> Thanx.
>
> Carl
>
> "Morten Wennevik"  wrote in message
> news:op.twwpsdsdklbvpo@ubuan...
>> On Sat, 11 Aug 2007 18:02:02 +0200, Carl Thomas
>>  wrote:
>>
>>> I have names in a data collection the include apostrophes like O'Hare.
>>> When
>>> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
>>> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that
>>> there
>>> is an unterminated string.   When I try using a DataAdapter and
>>> SqlCommandBuilder, it says I need and INSERT statement, although it will
>>> do
>>> data without the apostrophes.   Any idea how to handle these cases?  I've
>>> also tried parameters, but the results are the same.
>>>
>>> TIA
>>>
>>> Carl
>>>
>>>
>>>
>>
>> Carl, use SqlParameter to pass the data.  Saves you all these kinds of
>> troubles.
>>
>> --
>> Happy coding!
>> Morten Wennevik [C# MVP]
>
>
>


You really should give SqlParameter/OleDBParameter a try, apart from handling strings with ' they also to behind the scenes data conversion that potentially saves a whole lot of grief if you get trouble writing or reading database data.

-- 
Happy coding!
Morten Wennevik [C# MVP]
Date:Mon, 13 Aug 2007 16:32:24 +0200   Author:  

Re: Data with Apostrophes   
Right - they didn't help anything so I kept the simpler approach.  I realize 
it would be easier to take from one database and copy individual items into 
another, but using an intermediary array has worked in all cases so far and 
is transparent, if a little more complex.  Maybe I was using the parameters 
wrong; I'll check it out again.

Carl

"Kerry Moorman"  wrote in message 
news:CFE871FB-11B3-4A8D-8A0E-87DCCCBD6093@microsoft.com...

> Carl,
>
> I don't see any use of parameters, as you mentioned in your first post.
>
> Kerry Moorman
>
>
> "Carl Thomas" wrote:
>
>> The problem occurs at runtime from the following code snippet:
>>
>>                                             using (SqlDataReader drdr =
>> cmdIn.ExecuteReader())
>>                                             {
>>                                                 drdr.Read();
>>                                                 string latitude =
>> GetCoordinateString( drdr.GetString( 1 ) );
>>                                                 string longitude =
>> GetCoordinateString( drdr.GetString( 2 ) );
>>                                                 string strInsertString
>>                                                          = "INSERT INTO
>> AirportData (ICAO, Latitude, Longitude, Altitude,"
>>
>>         + " AirportName, CityName,"
>>
>>         + " StateProvinceName, CountryName)"
>>                                                          + "VALUES ('" +
>> drdr.GetString( 0 ) + "', '"
>>                                                                        +
>> latitude + " ', '"
>>                                                                        +
>> longitude + " ', '"
>>                                                                        +
>> drdr.GetString( 3 ) + "', '"
>>                                                                        +
>> drdr.GetString( 4 ) + "', '"
>>                                                                        +
>> drdr.GetString( 5 ) + "', '"
>>                                                                        +
>> drdr.GetString( 6 ) + "', '"
>>                                                                        +
>> drdr.GetString( 7 ) + "')";
>>                                                 using (SqlCommand 
>> cmdInsert
>> = new SqlCommand( strInsertString, cnOut ))
>>                                                 {
>> 
>> cmdInsert.ExecuteNonQuery();
>>                                                 }
>>                                             }
>> When it hits O'Hare as once instance, it does an SqlException at
>> ExecuteNonQuery claiming that there is an unterminated string.  I have 
>> since
>> found a way around it that blythly ignores the problem.  I've broken the
>> problem up to retrieve the data from one database using an SqlDataReader 
>> and
>> out it into a class list and then separately reading it from a class list
>> into an SqlDataAdapter for the insert.  It is a little less elegent, but
>> works without a problem.
>>
>> Carl
>>
>> "Kerry Moorman"  wrote in message
>> news:BB72B829-BA04-4BA8-8E3D-04E1EBBB528C@microsoft.com...
>> > Carl,
>> >
>> > Can you post your code where you use cmd.ExecuteNonQuery with 
>> > parameters
>> > and
>> > you still have problems?
>> >
>> > Kerry Moorman
>> >
>> >
>> > "Carl Thomas" wrote:
>> >
>> >> I have names in a data collection the include apostrophes like O'Hare.
>> >> When
>> >> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
>> >> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that
>> >> there
>> >> is an unterminated string.   When I try using a DataAdapter and
>> >> SqlCommandBuilder, it says I need and INSERT statement, although it 
>> >> will
>> >> do
>> >> data without the apostrophes.   Any idea how to handle these cases? 
>> >> I've
>> >> also tried parameters, but the results are the same.
>> >>
>> >> TIA
>> >>
>> >> Carl
>> >>
>> >>
>> >>
>>
>>
>> 
Date:Mon, 13 Aug 2007 10:35:01 -0400   Author:  

Re: Data with Apostrophes   
Actually, I misspoke - I did try the parameter approach, but it didn't help. 
Maybe I was using them wrong, but separating the read operations from one 
database and the write operations into a second one through an intermediate 
array worked.  If it was slightly less elegent and complex, it worked.  I'll 
give the parametric approach another go to help trim the code a bit.

Carl

"Carl Thomas"  wrote in message 
news:uzFLdWS3HHA.5240@TK2MSFTNGP02.phx.gbl...

>I haven't tried SqlParameters since I found a work around.  I may give it a 
>try since my solution was less elegent than I'd like (see my reply to Kerry 
>Moorman's post).  Somehow, I've never gotten around to SqlParameters, but 
>it might be a nice application to try.
>
> Thanx.
>
> Carl
>
> "Morten Wennevik"  wrote in message 
> news:op.twwpsdsdklbvpo@ubuan...
>> On Sat, 11 Aug 2007 18:02:02 +0200, Carl Thomas 
>>  wrote:
>>
>>> I have names in a data collection the include apostrophes like O'Hare. 
>>> When
>>> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
>>> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that 
>>> there
>>> is an unterminated string.   When I try using a DataAdapter and
>>> SqlCommandBuilder, it says I need and INSERT statement, although it will 
>>> do
>>> data without the apostrophes.   Any idea how to handle these cases? 
>>> I've
>>> also tried parameters, but the results are the same.
>>>
>>> TIA
>>>
>>> Carl
>>>
>>>
>>>
>>
>> Carl, use SqlParameter to pass the data.  Saves you all these kinds of 
>> troubles.
>>
>> -- 
>> Happy coding!
>> Morten Wennevik [C# MVP]
>
> 
Date:Mon, 13 Aug 2007 10:39:13 -0400   Author:  

RE: Data with Apostrophes   
All that you have to do is double up on them. Sinding "O''Hare" will actually 
send "O'Hare".
-- 
Tom Garth


"Carl Thomas" wrote:


> I have names in a data collection the include apostrophes like O'Hare.  When 
> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and 
> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that there 
> is an unterminated string.   When I try using a DataAdapter and 
> SqlCommandBuilder, it says I need and INSERT statement, although it will do 
> data without the apostrophes.   Any idea how to handle these cases?  I've 
> also tried parameters, but the results are the same.
> 
> TIA
> 
> Carl
> 
> 
> 
Date:Tue, 14 Aug 2007 07:42:01 -0700   Author:  

Re: Data with Apostrophes   
I assume by that you mean two apostrophes rather than a singlr quote.  OK - 
gotta remember that.  But it means I have to go back into the old database 
and change all the apostrophe-bearing words. I think I'll hold onto the 
DataAdapter approach I'm using now which seems to work.  I do want to try 
the SqlParameter approach with an INSERT since I suspect it may be a little 
faster.  I'll kepp this in mind though. Thanx

Carl

"Tom Garth"  wrote in message 
news:2AE689D2-A743-46D4-BBAE-AC8B1B977857@microsoft.com...

> All that you have to do is double up on them. Sinding "O''Hare" will 
> actually
> send "O'Hare".
> -- 
> Tom Garth
>
>
> "Carl Thomas" wrote:
>
>> I have names in a data collection the include apostrophes like O'Hare. 
>> When
>> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
>> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that 
>> there
>> is an unterminated string.   When I try using a DataAdapter and
>> SqlCommandBuilder, it says I need and INSERT statement, although it will 
>> do
>> data without the apostrophes.   Any idea how to handle these cases?  I've
>> also tried parameters, but the results are the same.
>>
>> TIA
>>
>> Carl
>>
>>
>> 
Date:Tue, 14 Aug 2007 22:48:03 -0400   Author:  

Re: Data with Apostrophes   
Ah, no. You don't have to exclude all Irish surnames from your database. 
This was tried at various points in time in the past with disastrous 
consequences. The Replace approach forces you to simply repeat any single 
quote (apostrophe) to two single quotes just before it's concatenated into a 
SQL string. However, as we've discussed, this approach is full of other 
issues. The "parameter" approach deals with what I call the O'Malley issue 
as well as date formatting and other issues you might not have encountered 
yet.

-- 
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Carl Thomas"  wrote in message 
news:eYQb7au3HHA.4436@TK2MSFTNGP03.phx.gbl...

>I assume by that you mean two apostrophes rather than a singlr quote.  OK - 
>gotta remember that.  But it means I have to go back into the old database 
>and change all the apostrophe-bearing words. I think I'll hold onto the 
>DataAdapter approach I'm using now which seems to work.  I do want to try 
>the SqlParameter approach with an INSERT since I suspect it may be a little 
>faster.  I'll kepp this in mind though. Thanx
>
> Carl
>
> "Tom Garth"  wrote in message 
> news:2AE689D2-A743-46D4-BBAE-AC8B1B977857@microsoft.com...
>> All that you have to do is double up on them. Sinding "O''Hare" will 
>> actually
>> send "O'Hare".
>> -- 
>> Tom Garth
>>
>>
>> "Carl Thomas" wrote:
>>
>>> I have names in a data collection the include apostrophes like O'Hare. 
>>> When
>>> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
>>> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that 
>>> there
>>> is an unterminated string.   When I try using a DataAdapter and
>>> SqlCommandBuilder, it says I need and INSERT statement, although it will 
>>> do
>>> data without the apostrophes.   Any idea how to handle these cases? 
>>> I've
>>> also tried parameters, but the results are the same.
>>>
>>> TIA
>>>
>>> Carl
>>>
>>>
>>>
>
> 
Date:Tue, 14 Aug 2007 21:09:57 -0700   Author:  

Re: Data with Apostrophes   
Be'gorra.  Since I'm starting ta be playin' with LINQ, can I assume that the 
same considerations will be applyin' there?

Carl

"William Vaughn"  wrote in message 
news:u26snIv3HHA.5804@TK2MSFTNGP05.phx.gbl...

> Ah, no. You don't have to exclude all Irish surnames from your database. 
> This was tried at various points in time in the past with disastrous 
> consequences. The Replace approach forces you to simply repeat any single 
> quote (apostrophe) to two single quotes just before it's concatenated into 
> a SQL string. However, as we've discussed, this approach is full of other 
> issues. The "parameter" approach deals with what I call the O'Malley issue 
> as well as date formatting and other issues you might not have encountered 
> yet.
>
> -- 
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant, Dad, Grandpa
> Microsoft MVP
> INETA Speaker
> www.betav.com
> www.betav.com/blog/billva
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no 
> rights.
> __________________________________
> Visit www.hitchhikerguides.net to get more information on my latest book:
> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
> -----------------------------------------------------------------------------------------------------------------------
>
> "Carl Thomas"  wrote in message 
> news:eYQb7au3HHA.4436@TK2MSFTNGP03.phx.gbl...
>>I assume by that you mean two apostrophes rather than a singlr quote. 
>> OK - gotta remember that.  But it means I have to go back into the old 
>>database and change all the apostrophe-bearing words. I think I'll hold 
>>onto the DataAdapter approach I'm using now which seems to work.  I do 
>>want to try the SqlParameter approach with an INSERT since I suspect it 
>>may be a little faster.  I'll kepp this in mind though. Thanx
>>
>> Carl
>>
>> "Tom Garth"  wrote in message 
>> news:2AE689D2-A743-46D4-BBAE-AC8B1B977857@microsoft.com...
>>> All that you have to do is double up on them. Sinding "O''Hare" will 
>>> actually
>>> send "O'Hare".
>>> -- 
>>> Tom Garth
>>>
>>>
>>> "Carl Thomas" wrote:
>>>
>>>> I have names in a data collection the include apostrophes like O'Hare. 
>>>> When
>>>> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
>>>> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that 
>>>> there
>>>> is an unterminated string.   When I try using a DataAdapter and
>>>> SqlCommandBuilder, it says I need and INSERT statement, although it 
>>>> will do
>>>> data without the apostrophes.   Any idea how to handle these cases? 
>>>> I've
>>>> also tried parameters, but the results are the same.
>>>>
>>>> TIA
>>>>
>>>> Carl
>>>>
>>>>
>>>>
>>
>>
> 
Date:Sun, 19 Aug 2007 17:44:33 -0400   Author:  

Re: Data with Apostrophes   
I'm noot sur laddie. I'm expecting eet will.

-- 
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Carl Thomas"  wrote in message 
news:%23sctloq4HHA.3940@TK2MSFTNGP05.phx.gbl...

> Be'gorra.  Since I'm starting ta be playin' with LINQ, can I assume that 
> the same considerations will be applyin' there?
>
> Carl
>
> "William Vaughn"  wrote in message 
> news:u26snIv3HHA.5804@TK2MSFTNGP05.phx.gbl...
>> Ah, no. You don't have to exclude all Irish surnames from your database. 
>> This was tried at various points in time in the past with disastrous 
>> consequences. The Replace approach forces you to simply repeat any single 
>> quote (apostrophe) to two single quotes just before it's concatenated 
>> into a SQL string. However, as we've discussed, this approach is full of 
>> other issues. The "parameter" approach deals with what I call the 
>> O'Malley issue as well as date formatting and other issues you might not 
>> have encountered yet.
>>
>> -- 
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant, Dad, Grandpa
>> Microsoft MVP
>> INETA Speaker
>> www.betav.com
>> www.betav.com/blog/billva
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no 
>> rights.
>> __________________________________
>> Visit www.hitchhikerguides.net to get more information on my latest book:
>> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
>> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
>> -----------------------------------------------------------------------------------------------------------------------
>>
>> "Carl Thomas"  wrote in message 
>> news:eYQb7au3HHA.4436@TK2MSFTNGP03.phx.gbl...
>>>I assume by that you mean two apostrophes rather than a singlr quote. 
>>>OK - gotta remember that.  But it means I have to go back into the old 
>>>database and change all the apostrophe-bearing words. I think I'll hold 
>>>onto the DataAdapter approach I'm using now which seems to work.  I do 
>>>want to try the SqlParameter approach with an INSERT since I suspect it 
>>>may be a little faster.  I'll kepp this in mind though. Thanx
>>>
>>> Carl
>>>
>>> "Tom Garth"  wrote in message 
>>> news:2AE689D2-A743-46D4-BBAE-AC8B1B977857@microsoft.com...
>>>> All that you have to do is double up on them. Sinding "O''Hare" will 
>>>> actually
>>>> send "O'Hare".
>>>> -- 
>>>> Tom Garth
>>>>
>>>>
>>>> "Carl Thomas" wrote:
>>>>
>>>>> I have names in a data collection the include apostrophes like O'Hare. 
>>>>> When
>>>>> I use a simple VC#/ADO.NET approach with an SQL INSERT statement and
>>>>> cmd.ExecuteNonQuery, it always hangs up on the apostrophe saying that 
>>>>> there
>>>>> is an unterminated string.   When I try using a DataAdapter and
>>>>> SqlCommandBuilder, it says I need and INSERT statement, although it 
>>>>> will do
>>>>> data without the apostrophes.   Any idea how to handle these cases? 
>>>>> I've
>>>>> also tried parameters, but the results are the same.
>>>>>
>>>>> TIA
>>>>>
>>>>> Carl
>>>>>
>>>>>
>>>>>
>>>
>>>
>>
>
> 
Date:Sun, 19 Aug 2007 15:23:28 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us