这是我的代码。没有显示错误。我插入到数据表中,但数据未显示在表中。任何人都可以解决这个问题吗?。
Public Class Form11
Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
Dim connection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=loginUser.mdb;")
Dim command As New OleDbCommand("SELECT COUNT(*) FROM [Staff]", connection)
command.Connection.Open()
Dim count As Int16 = Convert.ToInt16(command.ExecuteScalar())
command.Connection.Close()
count = count + 1
MsgBox(count)
Dim command1 As New OleDbCommand("INSERT INTO Staff ([ID], [username], [password]) VALUES (@id,@user,@pass)", connection)
With command1.Parameters
.AddWithValue("@id", count)
.AddWithValue("@user", txtUsername.Text)
.AddWithValue("@pass", txtPassword.Text)
End With
Using connection
command1.Connection.Open()
command1.ExecuteNonQuery()
End Using
command1.Connection.Close()
MsgBox("Added")
End Sub
End Class