string sql="select * from EatInfo where BigClass='xxx' and (Convert(double,price) between '"+m1+"' and '"+m2+"') order by AddTime desc";
含义是查价格为m1,m2间的产品,price是价格字段,为NVarChar类型
...全文
6269打赏收藏
数据类型转换问题?NVarChar到double
string sql="select * from EatInfo where BigClass='xxx' and (Convert(double,price) between '"+m1+"' and '"+m2+"') order by AddTime desc"; 含义是查价格为m1,m2间的产品,price是价格字段,为NVarChar类型
既然m1,m2是字符串,那这样就行了:
string sql="select * from EatInfo where BigClass='xxx' and (Convert(numeric(18,4),price) between "+m1+" and "+m2+") order by AddTime desc";