C# ACCESS 参数化SQL语句出错汇总

参数顺序错了,就会出错
不过是insert 还是 update

internal static int InsertProducts(TProducts products)
        {
            string sql = "insert into [products] ([name],[price],[pricing],[content],[time],[picture]) values (@name,@price,@pricing,@content,@time,@picture)";
            OleDbParameter[] parameters = new OleDbParameter[]
            {
                AccessHelper.Parameter("@name",products.StrName),
                AccessHelper.Parameter("@price",products.DecPrice,OleDbType.Numeric),
                AccessHelper.Parameter("@pricing",products.DecPricing,OleDbType.Numeric),
                AccessHelper.Parameter("@content",products.StrContent),
                AccessHelper.Parameter("@time",DateTime.Now,OleDbType.Date),
                AccessHelper.Parameter("@picture",products.StrPicture)
            };
            int intTemp = AccessHelper.ExecuteNonQuery(sql, parameters);
            SetSum();
            return intTemp;
        }

      AccessHelper.Parameter("@name",products.StrName),
                AccessHelper.Parameter("@price",products.DecPrice,OleDbType.Numeric),
                AccessHelper.Parameter("@pricing",products.DecPricing,OleDbType.Numeric),
                AccessHelper.Parameter("@content",products.StrContent),
                AccessHelper.Parameter("@time",DateTime.Now,OleDbType.Date),
                AccessHelper.Parameter("@picture",products.StrPicture)
参数顺序错了,就会出错
不过是insert 还是 update
posted @ 2011-04-18 23:54  hen  阅读(2826)  评论(0编辑  收藏  举报