Imports System.Data.OleDb Public Class InsertTest Private Sub Button1_Click(sender As Object,e As EventArgs) Handles Button1.Click Dim oledb1 As New OleDbConnection oledb1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\liang.accdb" oledb1.Open() If ConnectionState.Open Then Dim cmd1 As New OleDbCommand cmd1.Connection = oledb1 cmd1.CommandText = "Insert into 借书人(姓名,电话)values('" + TextBox1.Text + "'" + ",'" + TextBox2.Text + "')" cmd1.ExecuteNonQuery() oledb1.Close() End If End Sub End Class
注意:以下黄色区两边的是双引号
"Insert into 借书人(姓名,电话)values('" + TextBox1.Text + "'" + ",'" + TextBox2.Text + "')"