我正在使用以下代码创建将我的 DataTable 内容保存到并清空 mdb 数据库,所以首先我创建了 datata 表,当我尝试插入数据时出现以下错误:没有为一个或多个参数提供值,现在我认为此错误是由使用此链接中提到的 Text 引起的
但我不知道如何修复它,这是代码,我在注释行中得到异常
Dim cmd = cnn.CreateCommand
cmd.CommandText = "CREATE TABLE productstable(supplierid Integer ,catalogid Integer ,ccode Text ,cname Text,pother2 Text, pother3 Double, cprice Double, rank Integer, rankchange Integer , PD Double, PDP Double , TPD Double, TPDP Double, sprice Double, msprice Double, minprice Double, sopriceDB Double, pother4 Long, usedsuppliermargin Double, cimageurl Text, ccategory Integer, pricetaggroup Byte , spricemargingroup Byte)"
cmd.ExecuteNonQuery()
Dim ocmd As New OleDbCommand("INSERT INTO productstable(supplierid , catalogid, ccode,cname,pother2,pother3,cprice,rank,rankchange,PD,PDP,TPD,TPDP,sprice,msprice,minprice,sopriceDB,pother4,usedsuppliermargin,cimageurl,ccategory,pricetaggroup,spricemargingroup) VALUES (@supplierid , @catalogid, @ccode, @cname, @pother2, @pother3, @cprice, @rank, @rankchange, @PD, @PDP, @TPD, @TPDP, @sprice, @msprice, @minprice, @sopriceDB, @pother4, @usedsuppliermargin,@cimageurl,@ccategory,@pricetaggroup,@spricemargingroup)", cnn)
For i = 0 To mainDatatable.Rows.Count - 1
ocmd.Parameters.Add(New OleDbParameter("@supplierid", mainDatatable.Rows(i)("supplierid")))
ocmd.Parameters.Add(New OleDbParameter("@catalogid", mainDatatable.Rows(i)("catalogid")))
ocmd.Parameters.Add(New OleDbParameter("@ccode", mainDatatable.Rows(i)("ccode")))
ocmd.Parameters.Add(New OleDbParameter("@cname", mainDatatable.Rows(i)("cname")))
ocmd.Parameters.Add(New OleDbParameter("@pother2", mainDatatable.Rows(i)("pother2")))
ocmd.Parameters.Add(New OleDbParameter("@pother3", mainDatatable.Rows(i)("pother3")))
ocmd.Parameters.Add(New OleDbParameter("@cprice", mainDatatable.Rows(i)("cprice")))
ocmd.Parameters.Add(New OleDbParameter("@rank", mainDatatable.Rows(i)("rank")))
ocmd.Parameters.Add(New OleDbParameter("@rankchange", mainDatatable.Rows(i)("rankchange")))
ocmd.Parameters.Add(New OleDbParameter("@PD", mainDatatable.Rows(i)("PD")))
ocmd.Parameters.Add(New OleDbParameter("@PDP", mainDatatable.Rows(i)("PDP")))
ocmd.Parameters.Add(New OleDbParameter("@TPD", mainDatatable.Rows(i)("TPD")))
ocmd.Parameters.Add(New OleDbParameter("@TPDP", mainDatatable.Rows(i)("TPDP")))
ocmd.Parameters.Add(New OleDbParameter("@sprice", mainDatatable.Rows(i)("sprice")))
ocmd.Parameters.Add(New OleDbParameter("@msprice", mainDatatable.Rows(i)("msprice")))
ocmd.Parameters.Add(New OleDbParameter("@minprice", mainDatatable.Rows(i)("minprice")))
ocmd.Parameters.Add(New OleDbParameter("@sopriceDP", mainDatatable.Rows(i)("sopriceDP")))
ocmd.Parameters.Add(New OleDbParameter("@pother4", mainDatatable.Rows(i)("pother4")))
ocmd.Parameters.Add(New OleDbParameter("@usedsuppliermargin", mainDatatable.Rows(i)("usedsuppliermargin")))
ocmd.Parameters.Add(New OleDbParameter("@cimageurl", mainDatatable.Rows(i)("cimageurl")))
ocmd.Parameters.Add(New OleDbParameter("@ccategory", mainDatatable.Rows(i)("ccategory")))
ocmd.Parameters.Add(New OleDbParameter("@pricetaggroup", mainDatatable.Rows(i)("pricetaggroup")))
ocmd.Parameters.Add(New OleDbParameter("@spricemargingroup", mainDatatable.Rows(i)("spricemargingroup")))
ocmd.ExecuteNonQuery()
ocmd.Parameters.Clear()
Next