2017-02-18 79 views
0

這是在Windows 10 dotnetframework4.6.1執行PROGRAMMwin10不支持類型爲地理

public void GetData() 
{ 
    string sConnectionString; 
     sConnectionString = @"Data Source=www.somedomain.com;Initial Catalog=iislog;Persist Security Info=True;User ID=iislog;Password=password"; 

     SqlConnection Conn = new SqlConnection(sConnectionString); 
     Conn.Open(); 

     SqlDataAdapter adapter; 
     DataSet ds; 
     ds = new DataSet(); 

     adapter = new SqlDataAdapter("Select top 10 name From geo", Conn); 
     adapter.Fill(ds, "name"); 

     adapter = new SqlDataAdapter("Select top 10 geo From geo", Conn); 
     adapter.Fill(ds, "geo"); 

    } 

數據庫引擎SQLSEVER 2008毫秒, 地理是含有一個表中的字段字段 ,其類型是地理區域,以及其類型爲nvarchar(50)的另一個字段 。

當執行到陳述 adapter.Fill(ds,「geo」); 拋出異常,

但如果我在Windows 7中執行程序,沒有錯誤發生。

例外截圖:

表結構:

the table structure

+3

而不是讓這太容易,你沒有包括有關例外的細節? –

+0

添加了例外截圖。感謝 – step

回答

0

使安裝在Windows 10箱一定要Microsoft.SqlServer.Types組裝。支持SqlGeography不附帶.net。

+0

它不起作用 – step