Error converting data type varchar to bigint. Inline sql statements
This is the code i have used to get LocationID from database with MerchantID. I am getting an exception from Fill dataset part. Please help me out,. The error is Error converting data type varchar to bigint.
public DataSet getLocationID(long MerchantID)
{
//long LOCID = null;
try
{
SqlParameter[] parameters = new SqlParameter[]
{
new SqlParameter("@merchantID",MerchantID)
};
string strCommandTex开发者_运维百科t = "Select LocationID from Merchant_Location where MerchantID ='@merchantID' order by LocationID ASC";
Debug.WriteLine(strCommandText);
DataSet pds = new DataSet();
SqlHelper.FillDataset(DbConnString, System.Data.CommandType.Text, strCommandText, pds, new string[] { "LocID" }, parameters);
return pds;
}
catch (Exception ex)
{
//LogError("Error Occurred When Retrieving LocationID: " + MerchantID.ToString(), ex);
return null;
}
}
Get rid of the single quotes around @merchantID
in your query text, assuming that MerchantID is a bigint.
Lose the ticks.
Instead of ='@merchantID' order
use =@merchantID order
精彩评论