3

我正在创建:

public DataTable CreateEmptyTableGeometryPoint(int srid)
{
    DataTable dt = new DataTable();

    SqlDataAdapter adapter = new SqlDataAdapter(
        string.Format("SELECT * FROM Geometry_Point_SRID_{0}",srid), 
        connection);
    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
    adapter.FillSchema(dt, SchemaType.Source);

    return dt;
}

现在,我尝试了:

DataTable dtGeometry = dal.CreateEmptyTableGeometryPoint(srid);
DataRow rowGeometry = dtGeometry.NewRow();

rowGeometry["Geometry"] = SqlGeometry.Point(100.0, 300.0, srid);

我得到一个ArgumentException.

为什么我会得到这个异常?有人能帮我吗?

4

1 回答 1

0

之后添加一个断点DataRow rowGeometry = dtGeometry.NewRow()并检查您的架构。

仔细检查“几何”列的数据类型。它可能没有正确填写。

foreach(DataColumn column in rowGeometry.table.Columns)
{
    Console.WriteLine(column.DataType);
}
于 2013-02-20T01:33:39.997 回答