Should this work, I can't see a problem with it... but it's not working
SQL Code:
Private Sub myAddNew(ByVal CusRef As Integer) Dim ConnectionString As String Dim SQLString As String Dim whichButtonDialogResult As DialogResult Dim dbCommand As System.Data.OleDb.OleDbCommand Dim Connection As System.Data.OleDb.OleDbConnection ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data " ConnectionString += "Source=" & "Opticians.accdb " Connection = New System.Data.OleDb.OleDbConnection(ConnectionString) 'SQLString = "INSERT INTO SpecSalesTable (DateReceived) " SQLString = "Update SpecSalesTable " SQLString += "SET DateReceived = #" & Date.Today & "#" SQLString += "WHERE SpecSalesID = SpecIDTextBox.Text " whichButtonDialogResult = MessageBox.Show("Are you sure these details are correct?", "Update!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If whichButtonDialogResult = DialogResult.Yes Then Connection.Open() If CBool(ConnectionState.Open) Then dbCommand = New System.Data.OleDb.OleDbCommand(SQLString, Connection) Try dbCommand.ExecuteNonQuery() MessageBox.Show("Spectacles Returned, SpecSalesTable Updated! ") Catch ex As Exception MessageBox.Show(" Error updating... ") 'IF ERROR DISPLAYS MESSAGE End Try End If End If Connection.Close() End Sub




Reply With Quote
