值为什么取不出来?
帮我分析一下哪里写错了,为什么ProductName,Auther,Press,MarketPrice,MemberPrice,VIPPrice值都取不出来 ?
string connstr = ConfigurationManager.ConnectionStrings[ "MyStoreConnectionString "].ConnectionString;//数据库的连接字符串没有问题,在别的页面上测过了。
/*传进来的值,BigClass=1,SmallClass=1,ProductId=1 时,在查询分析器里测过了,能取出来一条记录。*/
string commstr = "select @ProductName=ProductName,@Auther=Auther,@Press=Press,@MarketPrice=MarketPrice,@MemberPrice=MemberPrice,@VIPPrice=VIPPrice from ProductDetails where BigClass= "+BigClass + " and SmallClass= "+ SmallClass+ " and ProductId= "+ProductId ;
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand commCart = new SqlCommand(commstr,conn);
SqlParameter ParamProduct = new SqlParameter ( "@ProductName ", SqlDbType.VarChar, 50);
SqlParameter ParamAuther = new SqlParameter( "@Auther ", SqlDbType.VarChar, 50);
SqlParameter ParamPress = new SqlParameter( "@Press ", SqlDbType.VarChar, 50);
SqlParameter ParamMark = new SqlParameter( "@MarketPrice ", SqlDbType.Decimal, 9);
SqlParameter ParamMem = new SqlParameter( "@MemberPrice ", SqlDbType.Decimal, 9);
SqlParameter ParamVIP = new SqlParameter( "@VIPPrice ", SqlDbType.Decimal, 9);
commCart.Parameters.Add(ParamProduct);
commCart.Parameters.Add(ParamAuther);
commCart.Parameters.Add(ParamPress);
commCart.Parameters.Add(ParamMark);
commCart.Parameters.Add(ParamMem);
commCart.Parameters.Add(ParamVIP);
string ProductName=Convert.ToString(commCart.Parameters[0].Value);
string Auther=Convert.ToString(commCart.Parameters[1].Value);