即使没有错误,保存数据也无法访问

时间:2019-04-08 07:04:24

标签: vb.net

嘿,我正在尝试使用此代码将其保存到我的访问数据库中,尽管没有错误,并且显示了已保存的数据,但我的访问数据库未接收到新数据。怎么了?

Private Sub savenew()
        Dim conn As New OleDbConnection
        conn = New OleDbConnection
        dbprovider = "Provider=Microsoft.ACE.OLEDB.12.0;"
        dbsource = "Data Source = FULL YUGIOH ACCESS DATABASE.accdb;"
        conn.ConnectionString = dbprovider & dbsource
        Dim reader As OleDbDataReader
        Dim command As OleDbCommand

        Try
            conn.Open()
            Dim query As String
            query = "insert into item(name) values ('" & TextBox4.Text & "')"
            command = New OleDbCommand(query, conn)
            reader = command.ExecuteReader
            MsgBox("data saved")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

(我数据库中的表称为item,列称为name。)

0 个答案:

没有答案