开发者

How to insert in to MDB using vb.net?

Dim MyInsert As String = "INSERT INTO Inventory(userid,
Type,Number) Values(" 开发者_JAVA百科& _
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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜