我正在尝试从存储过程中获取十进制值。但是,即使我在代码中的Management Studio中运行查询时,它仍会返回0.00M。有任何想法吗?
using (SqlConnection connection = new SqlConnection(connection))
using (connection)
{
SqlCommand comm = connection.CreateCommand();
comm.CommandType = CommandType.StoredProcedure;
comm.CommandText = "XXXXXXXX";
connection.Open();
comm.Parameters.AddWithValue("@ClientID", clientId);
comm.Parameters.AddWithValue("@Username", username);
comm.Parameters.AddWithValue("@UserDomain", userDomain);
comm.Parameters.AddWithValue("@GM_ID", goalMasterId);
SqlDataReader reader = comm.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
var decimalData = reader.GetDecimal(reader.GetOrdinal("Consumption"));
}
}
else
{
Console.WriteLine("No rows found.");
}
reader.Close();
}
我需要它返回一些值,例如:398908.49