我試圖插入一個特徵數據 - 多邊形到SQL 2008的ID型:爲nvarchar,GEOM =>類型:幾何SQL插入數據
這裏是我的代碼:
foreach (FeatureDataRow dsRow in ds.Tables[0])
{
string ID = (string)dsRow["Name"];
SharpMap.Geometries.Polygon geom = (SharpMap.Geometries.Polygon)dsRow.Geometry;
SqlConnection con = new SqlConnection(MapHelper.GetSQLConnectionString());
string cmdStr = "INSERT INTO table1 (ID, geom) VALUES (@ID, geometry::STGeomFromWKB(@geom))";
SqlCommand cmd = new SqlCommand(cmdStr, con);
//Store parameters with values to the collection
cmd.Parameters.AddWithValue("ID", ID);
cmd.Parameters.AddWithValue("geom", geom); //.DBType ???
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
我得到一個錯誤on cmd.ExecuteQuery:從對象類型SharpMap.Geometries.Polygon到已知的託管提供程序本機類型不存在映射
我不知道要爲geom參數設置.DBTYPE。