Sending SqlCommand.Parameters to SqlHelperParameterCache.CacheParameterSet ?

  • Thread starter Thread starter Dagoberto Flores
  • Start date Start date
D

Dagoberto Flores

Hi, I try in the Application Block to send the sqlCommand (object visual)
parameters to the SqlHelperParameterCache.CacheParameterSet(). Some code
is:

SqlHelperParameterCache.CacheParameterSet(CONN_STRING, spName,
sqlInsertComm.Parameters);

Where spName is the StoreProcedure (the sqlCommand, object visual). In
theory I send the parameters to cache, but the error message is:

C:\Documents and Settings\User\My Documents\Visual Studio
Projects\Taxes\NewMagAchat.cs(603): Argument '3': cannot convert from
'System.Data.SqlClient.SqlParameterCollection' to
'System.Data.SqlClient.SqlParameter[]'


Thanks

Dago Flores
 
Looks like the method you are calling is expecting an array and not a
collection.

Try something like:

SqlParameter[] a = new SqlParameter[sqlInsertComm.Parameters.Count];
sqlInsertComm.Parameters.CopyTo(a, 0);

Then pass a as the array of parameters.

Hi, I try in the Application Block to send the sqlCommand (object visual)
parameters to the SqlHelperParameterCache.CacheParameterSet(). Some code
is:

SqlHelperParameterCache.CacheParameterSet(CONN_STRING, spName,
sqlInsertComm.Parameters);

Where spName is the StoreProcedure (the sqlCommand, object visual). In
theory I send the parameters to cache, but the error message is:

C:\Documents and Settings\User\My Documents\Visual Studio
Projects\Taxes\NewMagAchat.cs(603): Argument '3': cannot convert from
'System.Data.SqlClient.SqlParameterCollection' to
'System.Data.SqlClient.SqlParameter[]'


Thanks

Dago Flores
 
Back
Top