VB 2010 INSERT INTO syntax error

2019-09-21 21:35发布

Hello Good Afternoon I have a program in VB.Net that will Input data from textboxes into Access Database here is sample image

enter image description here

This is the code I am using and it gives me an error

m = TextBox1.Text
b = "'" + TextBox2.Text + "'"
x = "'" + TextBox3.Text + "'"
d = TextBox4.Text
n = "'" + TextBox5.Text + "'"
Dim s2 As String
s2 = "insert into users2 ( num , name1 , pass , add , phone ) " & " values ( " + m + " , " + n + " , " + b + " , " + x + " , " + d + " ) "
Dim cmd2 As New OleDbCommand(s2, con)
cmd2.ExecuteNonQuery()

Looking forward that someone will enlighten my problem since its im starting to program.

TYSM for future help

标签: vb.net access
1条回答
走好不送
2楼-- · 2019-09-21 22:00
  1. You need to encapsulate values you want to insert into ''

. "values('" + m + "', '" + ...

2 I don't understand & operator between two parts of query in the beginning

查看更多
登录 后发表回答