I have some code that I converted from a vb.net site I used to have to c#. But I am getting an error.
At the line:
parameter.DbType = SqlDbType.Int;
The error is:
Cannot implicitly convert type 'System.Data.SqlDbType'
I don't have the error in VB.Net, why here and what cast would I have to use or do I need to convert it somehow.
Thanks,
Tom
Code:
// Private Code
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Private routine allowed only by this base class, it automates the task
// of building a SqlCommand object designed to obtain a return value from
// the stored procedure.
// ---
private SqlCommand BuildIntCommand(string storedProcName, IDataParameter[] parameters)
{
SqlCommand command = BuildQueryCommand(storedProcName, parameters);
SqlParameter parameter = new SqlParameter();
parameter.ParameterName = "ReturnValue";
parameter.DbType = SqlDbType.Int; <-- Error here
parameter.Size = 4;
parameter.Direction = ParameterDirection.ReturnValue;
parameter.IsNullable = false;
parameter.Precision = 0;
parameter.Scale = 0;
parameter.SourceColumn = string.Empty;
parameter.SourceVersion = DataRowVersion.Default;
parameter.Value = null;
command.Parameters.Add(parameter);
return command;
}
// Builds a SqlCommand designed to return a SqlDataReader,
// and not an actual integer value.
// ----
private SqlCommand BuildQueryCommand(string storedProcName, IDataParameter[] parameters)
{
SqlCommand command = new SqlCommand(storedProcName, myConnection);
command.CommandType = CommandType.StoredProcedure;
SqlParameter parameter = null;
if ((parameters != null)) {
foreach (SqlParameter parameter_loopVariable in parameters) {
parameter = parameter_loopVariable;
command.Parameters.Add(parameter);
}
}
return command;
}
At the line:
parameter.DbType = SqlDbType.Int;
The error is:
Cannot implicitly convert type 'System.Data.SqlDbType'
I don't have the error in VB.Net, why here and what cast would I have to use or do I need to convert it somehow.
Thanks,
Tom