I have this stored proc that returns many rows, but I only want the first row item. But I am not getting anything back.
SELECT CF_LTLFuelPct from CarrierFuelRates
WHERE CF_EffDate <= @CmpDate
AND CF_ExpDate >= @CmpDate
AND CF_CA_Code=@Mode
AND CF_Status=1
ORDER BY cf_EffDate DESC
here is my function where I am calling the stored proc.
public string GetFuelRate(DateTime dt, string mode)
{
string connString = ConfigurationManager.ConnectionStrings["ConnStrFuelOverRide"].ToString();
string FuelRate = "";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "spGetLTLFuelSurchargeRates";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@CmpDate", SqlDbType.DateTime).Value = dt;
cmd.Parameters.Add("@Mode", SqlDbType.VarChar).Value = mode;
try
{
using (SqlConnection conn = new SqlConnection(connString))
{
conn.Open();
FuelRate = (string)cmd.ExecuteScalar();
}
}
catch(Exception ex)
{
}
return FuelRate;
}
Thanks for any help
Ordinary Programmer
SELECT CF_LTLFuelPct from CarrierFuelRates
WHERE CF_EffDate <= @CmpDate
AND CF_ExpDate >= @CmpDate
AND CF_CA_Code=@Mode
AND CF_Status=1
ORDER BY cf_EffDate DESC
here is my function where I am calling the stored proc.
public string GetFuelRate(DateTime dt, string mode)
{
string connString = ConfigurationManager.ConnectionStrings["ConnStrFuelOverRide"].ToString();
string FuelRate = "";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "spGetLTLFuelSurchargeRates";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@CmpDate", SqlDbType.DateTime).Value = dt;
cmd.Parameters.Add("@Mode", SqlDbType.VarChar).Value = mode;
try
{
using (SqlConnection conn = new SqlConnection(connString))
{
conn.Open();
FuelRate = (string)cmd.ExecuteScalar();
}
}
catch(Exception ex)
{
}
return FuelRate;
}
Thanks for any help
Ordinary Programmer