0

I have an xsd with a DataRow that has a field of type NetSdoGeometry.sdogeometry. When I attempt to get the data, I can retrive all the fields from the table except for one. I get an error for the geometry field and no data. The geometry DOES have data but somehow it thinks that it is null:

GEOMETRY = 'r.GEOMETRY' threw an exception of type 'System.Data.StrongTypingException'

Here is the call to get the data:

MyDS.GisRow r = mDS.Gis.FindByGis_ID((decimal)aRow.Cells["Gis_ID"].Value);

Here are the properties for the GEOMETRY DataColumn:

AllowDBNull = True
AutoIncrement = False
AutoIncrementSeed = 0
AutoIncrementStep = 1
Caption = GEOMETRY
DataType = NetSdoGeometry.sdogeometry
DateTimeMode = UnspecifiedLocal
DefaultValue =
Expression =
MaxLength = -1
NullValue = (Throw exception)
ReadOnly = False
Source = GEOMETRY
Unique = False
Name = GEOMETRY

Here is the MyDS.Designer.cs for the dataset/geometry field:

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
            public NetSdoGeometry.sdogeometry GEOMETRY {
                get {
                    try {
                        return ((global::NetSdoGeometry.sdogeometry)(this[this.tableGis.GEOMETRYColumn]));
                    }
                    catch (global::System.InvalidCastException e) {
                        throw new global::System.Data.StrongTypingException("The value for column \'GEOMETRY\' in table \'Gis\' is DBNull.", e);
                    }
                }
                set {
                    this[this.tableGis.GEOMETRYColumn] = value;
                }
            }

There is data for the GEOMETRY field in the table for that record. Why is the GEOMETRY field coming back null and generating the StrongTypingException error for that field?

Thanks Before Hand

Rob
  • 59
  • 7

1 Answers1

0

Solved!

Here were the steps. Basically it involved recreating the field:

  1. From the xsd designer, right click on the GEOMETRY column from the table's design and select delete. (And if you see a column called GEOMETRY1, delete that also)

  2. From the xsd designer, right click on the table and choose "Configure", now re-add the GEOMETRY column to the query

  3. Select the Properties of the table, choose the GEOMETRY DataColumn and change its DataType from System.Object to NetSdoGeometry.sdogeometry

  4. Check all the Queries and remove the schema from in front of the table name if you plan on using this in more than one schema. For example "select * from myshema.table1" should be edited to "select * from table1"

  5. Rebuild the project and all set!

Note: If you are removing the schema name, make sure you do a search on your entire project for "myshema." to make sure you have totally removed it. And one more note, if you make a change to any query, it will add it back again and it will need to be remove again. Here is a more detailed explanation of the hard-coded schema names: http://social.msdn.microsoft.com/Forums/en-US/c89db0b1-b7ea-4b81-a222-03d375d36f7f/how-to-remove-oracle-schema-name-hardcoded-in-tableadapter-query?forum=adodotnetdataproviders

Rob
  • 59
  • 7