Saturday, February 25, 2012

Cant convert types

I ham trying to convert a 'System.Data.CommandType' to 'System.Web.UI.WebControls.SqlDataSourceCommandType'.

but I get

Error 4 Cannot implicitly convert type 'System.Data.CommandType' to 'System.Web.UI.WebControls.SqlDataSourceCommandType'. An explicit conversion exists (are you missing a cast?) D:\Inetpub\wwwroot\Help_Desk\App_Code\HelpDeskSql.cs 99 42 http://localhost/Help_Desk/

My problem is I cant seem to get a explicit conversion to work. if it cast it I get an.

Specified argument was out of the range of valid values.
Parameter name: value
. when running the page. but no build errors, does anyone know how to cast this?

Show us your exact code or markup that you're talking about, which is giving you the error.|||

if (cmdUpdate !=null)

{

HDS.UpdateCommand = cmdUpdate.CommandText;

HDS.UpdateCommandType = (SqlDataSourceCommandType)cmdUpdate.CommandType; //errror line

for (int i = 0; i < cmdUpdate.Parameters.Count; i++)

{

HDS.UpdateParameters.Add(cmdUpdate.Parameters[i].ParameterName, cmdUpdate.Parameters[i].Value.ToString());

}

}

No comments:

Post a Comment