我正在尝试使用AxBarCodeWiz将条形码图像插入数据库,这是一个生成条形码并显示为图片框的工具,我可以使用其内置属性来编辑条形码。
我的问题是,当我尝试将条形码插入数据库时,出现此错误,提示“列数与第1行的值计数不匹配”。我以为是因为我在数据库中使用了错误的数据类型,所以我将其数据类型更改为BLOB,但仍然错误也尝试了CHAR,但仍然是相同的错误。
如果重要的话,这是我用来将值插入数据库的代码
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Dim insertbarcode As String = "INSERT INTO eeldatabase.barcode(Barcode, ItemCode, Operation, BundleNumber, Color, Size, Quantity, Price, Amount) values( '" & AxBarCodeWiz3.Barcode & "', '" & txtItemCode.Text & "', '" & txtOperation.Text & "', '" & txtBundleNo.Text & "', '" & txtColor.Text & "', '" & txtSize.Text & "' '" & txtQuantity.Text & "', '" & txtPrice.Text & "', '" & txtAmount.Text & "')"
Dim answer As Integer
If txtItemCode.Text = "" Or txtOperation.Text = "" Or txtBundleNo.Text = "" Or txtColor.Text = "" Or txtSize.Text = "" Or txtQuantity.Text = "" Or txtPrice.Text = "" Or txtAmount.Text = "" Then
MessageBox.Show("Please complete the required fields!", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
answer = MsgBox("Add this Barcode to the database?", vbYesNo + vbQuestion, "Add Barcode")
If answer = vbYes Then
ExecuteQuery(insertbarcode)
MessageBox.Show("Barcode successfuly added!")
connection.Close()
connection.Dispose()
txtItemCode.Text = ""
txtOperation.Text = ""
txtBundleNo.Text = ""
txtColor.Text = ""
txtSize.Text = ""
txtQuantity.Text = ""
txtPrice.Text = ""
txtAmount.Text = ""
Else
MessageBox.Show("Barcode not inserted")
txtItemCode.Text = ""
txtOperation.Text = ""
txtBundleNo.Text = ""
txtColor.Text = ""
txtSize.Text = ""
txtQuantity.Text = ""
txtPrice.Text = ""
txtAmount.Text = ""
End If
connection.Close()
Dim table As New DataTable()
Dim adapter As New MySqlDataAdapter("SELECT * FROM eeldatabase.barcode", connection)
adapter.Fill(table)
dgvBarcode.DataSource = table
End If
End Sub
是否可以将此条形码插入我的数据库?如果不能,我只能使用它的文本值插入数据库中,因为这样做的主要目的是使用户能够扫描条形码并检索保存在数据库中的条形码,因此即使文本值也可以使用。