2017-02-18 38 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