SqlServerLayer adding filter fiewlds (where)

11/22/2013 6:01:34 AM
Total Posts 2

SqlServerLayer adding filter fiewlds (where)

Hi There

 

Is there anyone out there that can provide me with the basic syntax to add a filter to my layer(where statement)

Map loads but loads the full layer, I need to add a filter to it:  "Where name = 'ZA" so that only the layer for "ZA" loads, ie replacement for the following old stuff:

 

Dim sqlSelect As String = "select Name, Geom.STAsBinary() AS WkbGeometryCountry from COUNTRY_BNDS where name = '" & ConfigurationManager.AppSettings("CC").ToString() & "' "

 

My current code is as follows:

Dim connectionString As String = ConfigurationManager.ConnectionStrings("SpatialConnectionString").ToString()


Dim tableName As String = "COUNTRY_BNDS"

Dim sqlLayer As SqlServerLayer

sqlLayer = New SqlServerLayer(connectionString, tableName, "GEOM")
sqlLayer.FieldList = "Name"

sqlLayer.DataType = SqlServerDataType.Geometry

Dim layer As Layer = Map1.AddLayer(sqlLayer)

layer.LabelField = "NAME"
layer.ShowLabels = True
layer.LabelFont.Outline = True
layer.Symbol.Size = 2
layer.LabelFont.Size = 9
layer.Symbol.LineColor = Color.FromArgb(199, 172, 116)
layer.Symbol.FillColor = Color.FromArgb(242, 236, 223)
layer.Visible = True

 

With KInd Regards

 

Louis

 

 

 

11/22/2013 1:11:47 PM
MVP
Total Posts 323

Re: SqlServerLayer adding filter fiewlds (where)

sqllayer.FilterExpression = "name = '" & ConfigurationManager.AppSettings("CC").ToString() & "'"

11/25/2013 12:55:59 AM
Total Posts 2

Re: SqlServerLayer adding filter fiewlds (where)

Hi

 

Thank You for the response.

 

Appreciated