Adding strings with quotes to datagrid

I am working with an app that inserts directories and files from the filesystem into a datagridview. My problem is that when the directory name has an apostrophe (i.e. B's Clip) then program throws the following exception

System.Data.SyntaxErrorException was caught
Message="Syntax error: Missing operand after 's' operator."

and the directory recursion stops.

Any ideas on how I can fix this? Do I need to escape quotes in the data I send to the datagrid. If so, how can I do this?

thanks,

Luis


[563 byte] By [llebron] at [2007-12-22]
# 1

try to see if you can put an @ (at symbol) before the string

example:

string myString = @"whatever";

the @ causes it to escape the special meaning character, if any.

Are you also able to post some code?

Does this help in some way?

ahmedilyas at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2

The @ symbol causes an error in vb. Here are some bits of the code

For Each fldr In currFldr.GetDirectories

If String.Compare(fldr.Name, "System Volume Information") <> 0 Then

Me.AddGridItem(fldr.CreationTime, fldr.CreationTimeUtc, "", fldr.Extension, fldr.FullName, False, fldr.LastAccessTime, fldr.LastAccessTimeUtc, fldr.LastWriteTime, fldr.LastWriteTimeUtc, 0, fldr.Name, "Directory")

End If

Next fldr

Private Sub AddGridItem(ByVal CreationTime As Date, ByVal CreationTimeUtc As Date, ByVal DirectoryName As String, ByVal Extension As String, ByVal FullName As String, ByVal IsReadOnly As Boolean, ByVal LastAccessTime As Date, ByVal LastAccessTimeUtc As Date, ByVal LastWriteTime As Date, ByVal LastWriteTimeUtc As Date, ByVal Length As String, ByVal Name As String, ByVal FileType As String)

Me.DataGridViewSelectionsFiles.Rows.Add(bChecked, Name, Length, FileType, LastWriteTime, CreationTime, CreationTimeUtc, DirectoryName, Extension, FullName, IsReadOnly, LastAccessTime, LastAccessTimeUtc, LastWriteTimeUtc)

End Sub

llebron at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3

sorry my fault, I thought this was the C# forum - C# has the @ symbol.

I'll get back to you, im sure its an escape thing...

ahmedilyas at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...