更新ms访问数据库

时间:2018-04-12 11:17:20

标签: database vb.net

您好,从vb.net更新我的数据库时遇到问题 我收到一个错误,我没有按要求提供所有值,但在我的数据库中没有按要求设置任何值。 这是片段

  Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click

        connString = provider & dataFile

        myConnection.ConnectionString = connString

        myConnection.Open()



           2013\Projects\projectempdb.mdb"

            Dim str As String
            str = "update [EmployeeInfo] set [Designition] = '" + TextBox3.Text + "' , [TermsOfService] = '" + TextBox7.Text + "', [OtherQualification] = '" + TextBox4.Text + "', [Dolp] = '" + DateTimePicker1.Text + "', [Dor] = '" + DateTimePicker2.Text + "' Where [IdNo] = '" + TextBox2.Text + "'"
            Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
            Try
                cmd.ExecuteNonQuery()
                cmd.Dispose()
                '' myConnection.Close()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try



        End Sub

这是我的变量

 Dim provider As String = "Provider=Microsoft.jet.oledb.4.0;Data Source = "

    Dim dataFile As String = "C:\Users\JackOyee\Documents\Visual Studio 2013\Projects\projectempdb.mdb"
    Dim myConnection As OleDbConnection = New OleDbConnection

    Dim connString As String

我的导入

Imports System.Data.OleDb

0 个答案:

没有答案