1
这是我用来从数据库中使用MerchantID获取LocationID的代码。我从Fill数据集部分获得一个例外。请帮助我,。错误是将数据类型varchar转换为bigint。将数据类型varchar转换为bigint时出错。内联sql语句
public DataSet getLocationID(long MerchantID)
{
//long LOCID = null;
try
{
SqlParameter[] parameters = new SqlParameter[]
{
new SqlParameter("@merchantID",MerchantID)
};
string strCommandText = "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;
}
}
是LocationID可空? – 2010-08-31 23:35:30
Merchant_Location表中的MerchantID字段是varchar字段吗? – ngroot 2010-08-31 23:35:50