如何使用vb.net插入MDB?

发布于 2024-11-23 16:07:05 字数 316 浏览 12 评论 0原文

Dim MyInsert As String = "INSERT INTO Inventory(userid,
Type,Number) Values(" & _
txtEquipCat.text & "," & _
Type.Text & "," & _
Number.text & ")"

在执行此操作时,我得到了

语法错误:插入到语句

错误。

如何在MDB中插入类型和数字等关键字? 我想在插入时指定列名。

Dim MyInsert As String = "INSERT INTO Inventory(userid,
Type,Number) Values(" & _
txtEquipCat.text & "," & _
Type.Text & "," & _
Number.text & ")"

while executing this im getting

syntax error:Insert in to statement

error.

How to insert keywords like type and number in to MDB?
I want to specify the columnname while insert.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迟到的我 2024-11-30 16:07:05

首先,使用参数。其次,您的字符串混合物没有在文本周围添加“引号”。

也就是说, VALUES ('" & txtEquipCat.Text & "',...

但不要尝试像这样修复它。

使用参数: VALUES (?, ?, ?)

cmd.Parameters.AddWithValue("?", txtEquipCat.Text)

注意,对于参数,您不必担心任何引号。参数必须按顺序输入,因此第一个“?”对应于 txtEquipCat,第二个对应于 Type.Text,等等。

First of all, use parameters. Secondly, your string concoction isn't putting "quotes" around the text.

That is, VALUES ('" & txtEquipCat.Text & "',...

Don't try to fix it like that though.

Use parameters: VALUES (?, ?, ?)

cmd.Parameters.AddWithValue("?", txtEquipCat.Text)

Notice with parameters, you do not have to worry about any quotation marks. The parameters have to be entered in order, so the first "?" corresponds to txtEquipCat, the second to Type.Text, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文