开发者

Error converting data type varchar to bigint. Inline sql statements

开发者 https://www.devze.com 2023-01-14 03:07 出处:网络
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

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

精彩评论

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