Posted By Ben on 04-09-2009 07:34 AM
Dan and Charles,
The current desktop edition doesn’t support view for SQL 2008 and we will include it in the upcoming version. Here we create a temporary extension for you so you can have a try now. Do please note that as there are already corresponding classes in the desktop, we add “Temp” as the prefix in this extension and when the next version is out, you can remove this extension and directly use the intrinsic classes. Here are the codes to generate the view and connect to the view, have a try!
string connectString = "Data Source=192.168.0.58,1041;Initial Catalog=InternalDB;Persist Security Info=True;User ID=username;Password=password";
TempMsSql2008FeatureLayer sql2008Layer = new TempMsSql2008FeatureLayer(connectString, "cntry02", "ID");
sql2008Layer.Srid = 4326;
sql2008Layer.Open();
sql2008Layer.ExecuteNonQuery("create view cntry02view as select id, SIZE, geom from cntry02;");
sql2008Layer.Close();
sql2008Layer = new TempMsSql2008FeatureLayer(connectString, "cntry02view", "ID");
sql2008Layer.Srid = 4326;
sql2008Layer.Open();
sql2008Layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
winformsMap1.StaticOverlay.Layers.Add("Sql2008Layer", sql2008Layer);
Thanks,
Ben
Ben:
I am using Postgre Extension instead of MSSQL2008, but the code is similar.
My question is how to query the spatial data from more than one tables? In your above code, when you 1st create the sql2008Layer, you passed in the table name "cntry02", in the ExecuteNonQuery method, you passed in a query string which will retrieve the data from the same table "cntry02". Can I pass in a quer string which is something like this:
create view cntry02view as select cntry02.id,cntryo2.geom, table2.name where cntry02.id=table2.id
Any help is greatly appreciated!
Rose