ThinkGeo.com    |     Documentation    |     Premium Support

PostgreSqlFeatureLayer problem

Hello all,


I try to use postgresql to show map, but it can't run.


could you tell me where is wrong?


      Dim ConnStr As String = "Server=localhost;User Id=postgres; password=password; database=template_postgis;"

        Dim all_county As New PostgreSqlFeatureLayer(ConnStr, "twn_county", "gid")

        all_county.ZoomLevelSet.ZoomLevel08.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.PaleGreen, GeoColor.StandardColors.Yellow, 3)

         all_county.ZoomLevelSet.ZoomLevel08.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

        WinformsMap1.MapUnit = GeographyUnit.Meter

        Dim worldlayer As New LayerOverlay

        worldlayer.Layers.Add(all_county)

        WinformsMap1.Overlays.Add(worldlayer)

        all_county.Open()


        WinformsMap1.CurrentExtent = all_county.GetBoundingBox

        all_county.Close()


        WinformsMap1.Refresh()


    the exception error shows as attachment.



1676-error1.JPG (39.5 KB)

Carol, 
  
 Thanks for your post and question. 
  
 Just for a quick confirmation, did you reference the Npgsql.dll correctly? 
  
 Any more questions just feel free to let me know. 
  
 Thanks. 
  
 Yale 


Thanks for your reply, Yale 
 I think i refer the Npgsql.dll correctly. 
 I try to test link by other method. 
 it runs great. 
     Private Sub test_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles test_btn.Click 
         Dim ConnStr As String = “Server=localhost;User Id=postgres; password=password; database=template_postgis;” 
         Dim conn As NpgsqlConnection = New NpgsqlConnection(ConnStr) 
         Dim da As NpgsqlDataAdapter = New NpgsqlDataAdapter(“select * from twn_county;”, conn) 
         Dim ds As DataSet = New DataSet 
         da.Fill(ds) 
         DataGridView1.DataSource = ds 
         DataGridView1.DataMember = “Table” 
  
         conn.Open() 
         MessageBox.Show(“Connection is OK!!” + vbNewLine + “Link State:” + conn.State.ToString()) 
         conn.Close() 
     End Sub 
  
 So, I don’t know what’s wrong in my postgresql…could you give me some idea? 


have any idea??? 
 PostgreSqlFeatureLayer(connection, tableName, featureIdeColumn) 
 I want to make sure featureIdeColumn is…? number from 1 to N? number from 0 to N? or any else? 


Carol, 
  
 We have upgraded Npgsql from 1.98.2 to 2.0.6, but from your screen-shot, I noticed that you still refer the old version. Could you try to refer the new one and let me know the test result? 
  
 About the Feature Id issue, the number is depending on what you organize the data, we just use the column you pass in, the number is totally controlled by your side. 
  
 Thanks 
 James

Hello, James 
 it’s strange. My Npgsql is version2.0.8. Download from pgfoundry.org/frs/?group_id=1000140  (Npgsql2.0.8-bin-ms.net3.5sp1.zip) 
  
 and my postgreExtension downloads from 
 gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5242/afv/topic/Default.aspx 
 is postgreExtension old?

Carol, 
  
 That’s the problem, you should refer the Npgsql which is we provide in our product package, the version of it should be matched  the versio of our product. 
  
 Because the Npgsql is not compliant with previous version. We couldn’t support that sutiable for any version of it. Sorry about that. 
  
 Please refer the Npgsql.DLL from “Developer Reference” folder in MapSuite installation folder. 
  
 Thanks 
 James

Thanks, James 
 But my “Developer Reference” folder doesn’t have Npgsql.DLL. 
 That’s why i download from other website. 
 Or, could you give me new .dll?

Hi Carol, 
  
 The Npgsql.dll is in the folder “Developer Reference\Spatial Extensions\Postgre Extension”. Also, you should make sure that the Mono.Security.dll is at the same folder with Npgsql.dll. 
  
 Hope this helps and any more questions please let us know. 
  
 Thanks, 
  
 Sun 


Oh~Thanks, Sun 
 I think I got it. 
 I search wrong path… 
 “Developer Reference\DesktopEdition  :( 


Sun, Thanks for your help. We did some update on the version of Npgsql.dll, that cause the misunderstanding, Carol. 
  
 Thanks. 
  
 Yale