VB syntax - quotes in string


Author
Message
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I am using guid keys.



In a custom data source BO for a report I am putting a filter on a child cursor



Basically I want the filter to be "cclientkey =" and then the guid as a string - but of course in quotes



_policydisplay.SourceBO.Filter = "cclientkey = " & Me.ckey.ToString



doesn't work as the guid is not surrounded by quote in the resulting filter string.



I googled and tried things like



Dim quotes As Char = ChrW(34)

Dim filtstr As String = "cclientkey = " & quotes & Me.ckey.ToString & quotes

_policyDisplay.SourceBO.Filter = filtstr





Dim filtstr As String = "cclientkey = """ & Me.ckey.ToString & """"

_policyDisplay.SourceBO.Filter = filtstr



etc and no joy



Then reverted to the old Foxpro way



Dim filtstr as String = "cclientkey = '" & me.ckey.toString & "'" ( using single quotes to surround the guid )

and it works.



But a single quote to surround a string will throw and error. Is this some magic the old Foxers at Microfour have made possible? Never saw any solution like this in VB land? And what other ways are there to do this that work?















Reply
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I don't think has anything to do with either SQL Server or SF. This is an ADO.NET thing. I'm pretty sure (I haven't looked it up in source code yet, but the SF guys don't tend to build stuff that already exists) they just set the filter on the current view of the datatable. So, I think something like this is actually going on when you set the filter:



'-- This is the BO syntax

myBo.Filter = "stringColumn = 'somefilter value'"



'-- Under the covers, Expanded to make it clear

Dim view As System.Data.DataView = myBo.CurrentDataView

view.RowFilter = "stringColumn = 'somefilter value'"





Based on this, single quotes makes sense, because MS knows that you'll be setting the value of the filter in code and that means that single quotes will work better. Here is info on the RowFilter property of the DataView:



http://msdn.microsoft.com/en-us/library/system.data.dataview.rowfilter.aspx



Again, I think this is what's going on. I didn't get a chance to look at the source, but this is what I'd expect.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Charles R Hankey - 16 Years Ago
Edhy Rijo - 16 Years Ago
Charles R Hankey - 16 Years Ago
Edhy Rijo - 16 Years Ago
Charles R Hankey - 16 Years Ago
Charles R Hankey - 16 Years Ago
Edhy Rijo - 16 Years Ago
Charles R Hankey - 16 Years Ago
Keith Chisarik - 16 Years Ago
Greg McGuffey - 16 Years Ago
Charles R Hankey - 16 Years Ago
Charles R Hankey - 16 Years Ago
Charles R Hankey - 16 Years Ago
Greg McGuffey - 16 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search