Imports System.Data
Imports System.Data.SqlClient
Public Class Reservation
Dim sqlConn As SqlConnection
Private Sub Reservation_Load(sender As Object, e As EventArgs) Handles MyBase.Load
sqlConn = New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|EasyReserv.mdf;Integrated Security=True")
End Sub
Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
Dim addSQL As String = "INSERT INTO CUSTOMER ( customerID, name, contactNumber, email ) VALUES (1, 'James', '012444444','james@gmail.com')"
Dim addCmd As SqlCommand = New SqlCommand(addSQL, sqlConn)
sqlConn.Open()
addCmd.ExecuteNonQuery()
sqlConn.Close()
End Sub
End Class
代码里面没有错误,ExecuteNonQuery
也返回1,但是我的数据库中没有记录。