急!insert into 语句问题!
在注册界面注册信息进Access数据库中去Imports System.Data
Imports System.Data.oledb
Public Class register
Dim mybind As BindingManagerBase
Dim olestr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=register.mdb"
Dim oleconn As New OleDbConnection(olestr)
Dim oleadap As New OleDbDataAdapter()
Dim oledset As New DataSet()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
oleconn.Open()
Dim id As New OleDbParameter("@id", OleDbType.Char, 10)
Dim password As New OleDbParameter("@password", OleDbType.Char, 10)
Dim name As New OleDbParameter("@name", OleDbType.Char, 10)
Dim olesql As String =
"insert into t_register(id,password,name)" & "values(@id,@password,@name)"
Dim olecmd As New OleDbCommand(olesql, oleconn)
olecmd.Parameters.Add(id)
olecmd.Parameters.Add(password)
olecmd.Parameters.Add(name)
id.Value = TextBox1.Text
password.Value = TextBox2.Text
name.Value = TextBox4.Text
olecmd.ExecuteNonQuery()
oleconn.Close()
End Sub
异常:在olecmd.ExecuteNonQuery()处提示 :INSERT INTO 语句的语法错误。
不知道怎么回事?谢谢各位大虾解答下
--------------------编程问答-------------------- "insert into t_register(id,[password],[name]) values('"& id &"','"& password &"','"& name &"') "
字符型变量引用:'"& 变量名 &"'
数值型变量引用:"& 变量名 &" --------------------编程问答-------------------- 像那样改的话
还是有问题啊 --------------------编程问答--------------------
Dim olesql as string = "insert into t_register(id,password,name) values(?,?,?)"
补充:VB , 数据库(包含打印,安装,报表)