1

Hello am having problems updating my database from vb.net from am getting an error that I have not provided all the values as required though in my database no values are set as required. here is the snippet

  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

here are my variables

 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

my import

Imports System.Data.OleDb
braX
  • 11,506
  • 5
  • 20
  • 33
Jackson
  • 315
  • 3
  • 12
  • Off topic, but why aren't you using parameterized queries? Your approach is just an invitation to an sql injection attack. – Honeyboy Wilson Apr 12 '18 at 11:35
  • Is `IdNo` really a char field? I suspect it's an integer, if it's not, it should be. But anyhow, I would start by making sure you're only wrapping char column values with single quotes and not numbers. I'm not familiar with an error that says "no values are set as required", is that exactly what it says? – soohoonigan Apr 12 '18 at 13:08
  • Is this code as-is? You commented out most of the SQL string. – Jacob H Apr 12 '18 at 13:37

0 Answers0