开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜