468,741 Members | 1,899 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,741 developers. It's quick & easy.

getting " Object type cannot be converted to target type." with dataAdapter using storedProc

i'm getting an error when trying set my dataAdapter's selectCommand. the
sqlStatement is a storedProc which takes parameters, so it's constructed as:

sqlSelectCommand1.CommandText = "[uspProjectListUser]";

sqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure;

sqlSelectCommand1.Connection = sqlConnection1;

sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@RETURN_VALUE" ,
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
false, ((System.Byte)(0)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));

sqlSelectCommand1.Parameters.Add("@iCompanyID", SqlDbType.Int).Value = 1;

sqlSelectCommand1.Parameters.Add("@iUserID", SqlDbType.Int).Value = 4;

when i pass this to my dataAdapter as:

oDataAdapter.SelectCommand = sqlSelectCommand1;

i get an error:

" Object type cannot be converted to target type."

i've tried commenting out the parameters, and then have no problems setting
the dataAdapter's selectCommand.

how can i fix this?

tks

Nov 17 '05 #1
0 1365

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

188 posts views Thread by infobahn | last post: by
3 posts views Thread by Stephen Gennard | last post: by
3 posts views Thread by =?Utf-8?B?Sm9l?= | last post: by
19 posts views Thread by Daniel Pitts | last post: by
1 post views Thread by CARIGAR | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.