这是我添加数据的代码。但是没有数据可以新插入数据库,因为错误来了,说标准表达式中的数据类型不匹配。为什么是?????????
Imports System.Data.OleDb
Public Class Form1
Dim con As OleDbConnection
Dim myAdapter As OleDbDataAdapter
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\DELL\Documents\Visual Studio 2012\Projects\WindowsApplication9\WindowsApplication9\NIBM.accdb")
con.Open()
myAdapter = New OleDbDataAdapter("INSERT INTO Driverdetails values(@DriverNo,@DriverName,@DriverAge,@DriverAddress)", con)
myAdapter.SelectCommand.Parameters.AddWithValue("@Driver No", TextBox1.Text)
myAdapter.SelectCommand.Parameters.AddWithValue("@Driver Name", TextBox2.Text)
myAdapter.SelectCommand.Parameters.AddWithValue("@Driver Age", TextBox3.Text)
myAdapter.SelectCommand.Parameters.AddWithValue("@Driver Address", TextBox4.Text)
myAdapter.SelectCommand.ExecuteNonQuery()
con.Close()
End Sub