By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,184 Members | 1,522 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,184 IT Pros & Developers. It's quick & easy.

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

P: n/a
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;

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?


Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.