hi…
I am trying to display data from postgresql database on map with thinkgeo. And here is my code, but I got an error that "Object reference not set to an instance of an object". And the data is with raster format. Can you please solve this error as early as possible.
Dim connectString1 As String = "Server=localhost;User Id=postgres;Password=123;DataBase=MyDatabase;"
Dim postgreLayer As PostgreSqlFeatureLayer = New PostgreSqlFeatureLayer(connectString1, "rast", "rid")
postgreLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1
postgreLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
overlays.LayerOverlay("MAPA_FOTO_1").Layer("ShapeLayer", postgreLayer).IsBaseOverlay(False)
Thanks & regards
SAMIR
How can I display data from postgresql database with thinkgeo
Hi Samir,
Thanks for your post, we tried to recreat your problem with your code, but it didn’t show up on our end with attached code.
Here are some instructions you might be checked:
1. Make sure all the postgresql dlls are referenced. There are two import dlls related with postgresql: Npgsql.dll and PostgreExtension.dll.
2. Make sure you can the PostgreSqlFeaturelayer can conncect with the database. Please try the below codes to do a simple test where you can just put it in a console project:
Dim connectString1 As String = "…"
Dim postgreLayer As PostgreSqlFeatureLayer = New PostgreSqlFeatureLayer(connectString1, “rail”, “oid”)
postgreLayer.Open()
Dim boundingBox As RectangleShape = postgreLayer.FeatureSource.GetBoundingBox()
3. In order to make sure if is it related with the Raster data, please try to get some features after you connect to the postgresql database. Following the steps 2, appending the below codes to test
Dim features As Collection(Of Feature) = postgreLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns)
4. Is it possible for you to send your database to us if the above 3 steps still can’t help us to position the root of the issue.
Waiting for your futher information.
Summer
003_002_001_samplecode.txt (1.19 KB)