Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ExecuteScaler

Status
Not open for further replies.

kss444

Programmer
Joined
Sep 19, 2006
Messages
306
Location
US
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
 
Resolved..

Ordinary Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top