SQLDataAdapter.Fill fails after call to SQLDataAdapter.FillSchema

Z

zdrakec

Hullo:

I pass a new datatable to SQLDataAdapter.FillSchema, specifying that it use SchemaType.Mapped. The particular select command, hits a table that has only one integer field, the first, which is an identity column and the primary key.
Immediately after calling FillSchema, I call Fill, again passing the datatable.
The call to Fill is failing with this error message:
"Cannot convert object of type 'System.Data.SqlTypes.SqlInt32' to object of type 'System.Int64'."
So I checked, and indeed the datatable's first column is of type SqlInt32. Experimenting, I tried setting it, after the FillSchema call, to be SqlInt64, but got the same result.
What I am doing wrong?

Thanks much,
zdrakec
 
Z

zdrakec

Hullo:



I pass a new datatable to SQLDataAdapter.FillSchema, specifying that it use SchemaType.Mapped. The particular select command, hits a table that has only one integer field, the first, which is an identity column and the primary key.

Immediately after calling FillSchema, I call Fill, again passing the datatable.

The call to Fill is failing with this error message:

"Cannot convert object of type 'System.Data.SqlTypes.SqlInt32' to object of type 'System.Int64'."

So I checked, and indeed the datatable's first column is of type SqlInt32. Experimenting, I tried setting it, after the FillSchema call, to be SqlInt64, but got the same result.

What I am doing wrong?



Thanks much,

zdrakec

Actually, I see that if I have the datatable's ReturnProviderSpecificTypes set to True, this is the culprit. Is there a workaround? I actually need to know the SQL types, I would like to avoid using multiple tables for this...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top