Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have error when import shapefile into sqlserver with mapwingis and c#. error like this:
there is an object named "geometry column" in the database import shape into sql server


What I have tried:

help me please!!
here is my code:
<pre> public static void ImportOgrLayer()
        {
            int layerHandle = App.Legend.SelectedLayer;
            if (layerHandle == -1) return;

            var sf = App.Map.get_Shapefile(layerHandle);
            if (sf == null)
            {
                MessageHelper.Info("Lớp được chọn không phải kiểu vector.");
                return;
            }

            //using (var form = new OgrConnectionForm())
            //{
            //    if (form.ShowDialog(MainForm.Instance) == DialogResult.OK)
            //    {
                    string connectionString = "MSSQL:server=" + Properties.Settings.Default.server.ToString() + ";database=" + Properties.Settings.Default.database.ToString() + ";trusted_connection=no;Persist Security info =True;OVERWRITE=YES;uid=" + Properties.Settings.Default.user .ToString()+ ";pwd=" + Properties.Settings.Default.password.ToString() + "";

                    var ds = new OgrDatasource();
                    ds.Open(connectionString);
           
                string layerName = App.Map.get_LayerName(layerHandle);
                    layerName = layerName.Replace(".", "_");
                    using (var importForm = new OgrImportShapefile(layerName))
                    {
                        if (importForm.ShowDialog(MainForm.Instance) == DialogResult.OK)
                        {
                            layerName = importForm.LayerName;
                    
                            if (!ds.ImportShapefile(sf, layerName, "OVERWRITE = YES", tkShapeValidationMode.NoValidation))
                            {
                                MessageHelper.Warn("Lỗi khi thêm shapefile: " + ds.GdalLastErrorMsg);
                            }
                            else
                            {
                                MessageHelper.Info("Lớp đã được thêm: " + layerName);
                            }
                        }
                    }
                    
            //    }
            //}
        }
Posted
Updated 9-Jan-19 19:41pm
Comments
ZurdoDev 10-Jan-19 8:20am    
Contact whoever makes mapwingis
Ma Con 12-Jan-19 4:46am    
thanks you!! i will try it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900