vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Has anyone had any success retrieving spatial data via an ODBC connection? The following C# code snippet throws a NullReferenceException when the row size gets over 32K (estimate). It works absolutely fine for smaller row sizes. The column 'shape' is defined as st_geometry. The error occurs at line 5 (i.e. the reader.Read() stmt). The debugger tells me that the variable Reader is not null. Any ideas to try before I log a call with IBM? OdbcConnection conn = new OdbcConnection("DSN=testdb"); OdbcCommand cmd = new OdbcCommand("select st_asbinary(shape) from test1",conn); conn.Open(); OdbcDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { //NULL EXCEPTION THROWN HERE long rowLength = reader.GetBytes(0, 0, null, 0, 0); byte [] b = new byte[rowLength]; long bufferPos = 0; long len; do { len = reader.GetBytes(0, bufferPos, b, Convert.ToInt32(bufferPos), 4096); bufferPos += len; } while (bufferPos < rowLength); } reader.Close(); conn.Close(); |