gpt4 book ai didi

mysql - VB.net - 您的 SQL 语法有错误;

转载 作者:行者123 更新时间:2023-11-29 17:14:43 25 4
gpt4 key购买 nike

我有问题,我想在我的数据库中输入数据,但我收到一条错误消息(您的 SQL 语法有错误;请检查与 ypur MariaDB 服务器版本对应的手册,以获取在“unique”附近使用的正确语法、partno、boxs、pcs、modul、p_lane)值(1、'T103'、'16581-57020',3,1',位于第 1 行)

但在检查了我相应使用的语法后

这是我的代码

 ElseIf ComboBox1.Text = "TAPPING PLAN TMC" Then
Dim cmd As New MySqlCommand("insert into s_unpackingtmc(no, unique, partno, boxs, pcs, modul, p_lane) VALUES (@Column1, @Column2, @Column3, @Column4, @Column5, @Column6, @Column7)", conn)
Try


For i As Integer = 0 To (DataGridView1.Rows.Count - 2)

no1 = DataGridView1.Rows(i).Cells(0).Value
unique1 = DataGridView1.Rows(i).Cells(1).Value
partno1 = DataGridView1.Rows(i).Cells(2).Value
boxs1 = DataGridView1.Rows(i).Cells(3).Value
pcs1 = DataGridView1.Rows(i).Cells(4).Value
modul1 = DataGridView1.Rows(i).Cells(5).Value
plane1 = DataGridView1.Rows(i).Cells(6).Value


cmd.Parameters.AddWithValue("@Column1", no1)
cmd.Parameters.AddWithValue("@Column2", unique1)
cmd.Parameters.AddWithValue("@Column3", partno1)
cmd.Parameters.AddWithValue("@Column4", boxs1)
cmd.Parameters.AddWithValue("@Column5", pcs1)
cmd.Parameters.AddWithValue("@Column6", modul1)
cmd.Parameters.AddWithValue("@Column7", plane1)
cmd.ExecuteNonQuery()
cmd.Parameters.Clear()
Next
MsgBox("Data Berhasil Diupload", MsgBoxStyle.Information, "Information")
Call tampildata3()

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Information, "Information")
cmd.Dispose()
Call tampildata3()



End Try

最佳答案

根据 MariaDB 文档 keywordsconstraintsUNIQUE是表唯一约束定义的保留关键字:

The UNIQUE keyword means that the index will not accept duplicated values, except for NULLs. An error will raise if you try to insert duplicate values in a UNIQUE index.

For UNIQUE keys, PRIMARY KEYs and FOREIGN KEYs, you can specify a name for the constraint, using the CONSTRAINT keyword. That name will be used in error messages.

您可以根据每种模式使用反引号或双引号(分别为标准或 ANSI SQL 模式,请参阅 related issue )或将其重命名为其他非关键字标识符:

标准模式

insert into s_unpackingtmc(no, `unique`, partno, boxs, pcs, modul, p_lane) VALUES (@Column1, @Column2, @Column3, @Column4, @Column5, @Column6, @Column7)

ANSI SQL模式

insert into s_unpackingtmc(no, "unique", partno, boxs, pcs, modul, p_lane) VALUES (@Column1, @Column2, @Column3, @Column4, @Column5, @Column6, @Column7)

关于mysql - VB.net - 您的 SQL 语法有错误;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51700446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com