471,348 Members | 1,339 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Cast Misbehaves in 1.1 library running in a 2.0 App


I have this annoying problem with a cast failing from a DAL that was created
in 1.1 that I have included in a 2.0 app.

Every stored proc in our system uses an integer parameter to return an error
code. The following code works fine in 1.1 apps, and from a test app I made
in fully 2.0 apps. However, when I try to use the DAL from a 2.0 app that
uses the 1.1 compiled DAL, the following cast throws an invalid cast
exception (System.InvalidCastException: Specified cast is not valid.)

cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int,
4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed,


// Execute query.
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;

Is anyone able to confirm if this is a bug in the Framework, expected
behaviour, or otherwise?

Dec 29 '05 #1
0 748

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Luke Dalessandro | last post: by
5 posts views Thread by Nick Flandry | last post: by
15 posts views Thread by David | last post: by
6 posts views Thread by Lore Leunoeg | last post: by
1 post views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.