所以我遇到了一个问题,我终于得到了没有错误的代码,但数据库实际上没有显示更新。
我运行了一些代码,我认为它会转到.pdb文件。它会一直到那里只使用.mdb文件作为模板吗?
Private Sub NextButton_Click(sender As Object, e As EventArgs) Handles NextButton.Click
Dim count As Integer = 0
Dim insertSql As String = "INSERT INTO StudentTable(BadgeNo,FirstName,LastName,SAPID,Email,Phone,College) VALUES (?,?,?,?,?,?,?)"
Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""C:\Users\larsennicholasg\Documents\Visual Studio 2012\Projects\SSCLogin\SSCLogin\My Project\SSCStudent.mdb"""
Using conn As New OleDbConnection(connStr), cmd As New OleDbCommand(insertSql, conn)
cmd.Parameters.Add("?", OleDbType.Integer).Value = CInt(BadgeNoTextBox.Text)
cmd.Parameters.Add("?", OleDbType.WChar, 255).Value = FirstNameTextBox.Text
cmd.Parameters.Add("?", OleDbType.WChar, 255).Value = LastNameTextBox.Text
cmd.Parameters.Add("?", OleDbType.Integer).Value = CInt(SAPSIDTextBox.Text)
cmd.Parameters.Add("?", OleDbType.WChar, 255).Value = EmailTextBox.Text
cmd.Parameters.Add("?", OleDbType.WChar, 255).Value = PhoneTextBox.Text
cmd.Parameters.Add("?", OleDbType.WChar, 255).Value = CollegeComboBox.Text
conn.Open()
If (cmd.ExecuteNonQuery() = 1) Then
MessageBox.Show("Success")
Else
MessageBox.Show("Nerp")
End If
conn.Close()
End Using
Me.Hide()
TestPull.Show()
End Sub