I'm showing 2 pieces of code the first one works fine. The second one is the exact same code with one additional item added to it. and it does not work.
![Name: Screenshoot of DB.png
Views: 26
Size: 78.8 KB]()
I added the line IsDown = @IsDown in the SQL code and mycommand.Parameters.AddWithValue("@IsDown", chkIsDown.Checked) in th
e add with values section.
Thanks
Code:
Sub SaveData()
Dim mycommand As OleDbCommand = New OleDb.OleDbCommand("SELECT * FROM tblWorkOrder WHERE WOClosed = False AND DeletedWO = False")
Dim MYCloseDate As String
Dim SQLQuery = <sql> UPDATE tblWorkOrder SET WorkOrderCompletedDate= @WorkOrderCompletedDate,
Notes = @Notes,
WorkPerformed = @WorkPerformed,
CompletedBy = @CompletedBy,
SanitizedBy = @SanitizedBy,
WOClosed = @WOClosed,
</sql>
MYCloseDate = DateTimePicker1.Value
mycommand.Connection = con
' The Where stament was added because it showed up as text in the <SQL> text
mycommand.CommandText = SQLQuery.Value & "WHERE WorkOrderId = " & txtWorkOrderID.Text
con.Open()
mycommand.Parameters.AddWithValue("@WorkOrderCompletedDate", MYCloseDate)
mycommand.Parameters.AddWithValue("@Notes", txtNotes.Text)
mycommand.Parameters.AddWithValue("@WorkPerformed", txtWorkCompleted.Text)
mycommand.Parameters.AddWithValue("@CompletedBy", cboWorkCompletedBy.Text)
mycommand.Parameters.AddWithValue("@SanitizedBy", cboMachineSanitizedBy.Text)
mycommand.Parameters.AddWithValue("@WOClosed", True)
mycommand.Parameters.AddWithValue("@WorkOrderID", txtWorkOrderID.Text)
Try
mycommand.ExecuteNonQuery()
con.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
con.Close()
End Try
End Sub
Code:
Sub SaveData()
Dim mycommand As OleDbCommand = New OleDb.OleDbCommand("SELECT * FROM tblWorkOrder WHERE WOClosed = False AND DeletedWO = False")
Dim MYCloseDate As String
Dim SQLQuery = <sql> UPDATE tblWorkOrder SET WorkOrderCompletedDate= @WorkOrderCompletedDate,
Notes = @Notes,
WorkPerformed = @WorkPerformed,
CompletedBy = @CompletedBy,
SanitizedBy = @SanitizedBy,
WOClosed = @WOClosed,
IsDown = @IsDown
</sql>
MYCloseDate = DateTimePicker1.Value
mycommand.Connection = con
' The Where stament was added because it showed up as text in the <SQL> text
mycommand.CommandText = SQLQuery.Value & "WHERE WorkOrderId = " & txtWorkOrderID.Text
con.Open()
mycommand.Parameters.AddWithValue("@WorkOrderCompletedDate", MYCloseDate)
mycommand.Parameters.AddWithValue("@Notes", txtNotes.Text)
mycommand.Parameters.AddWithValue("@WorkPerformed", txtWorkCompleted.Text)
mycommand.Parameters.AddWithValue("@CompletedBy", cboWorkCompletedBy.Text)
mycommand.Parameters.AddWithValue("@SanitizedBy", cboMachineSanitizedBy.Text)
mycommand.Parameters.AddWithValue("@WOClosed", True)
mycommand.Parameters.AddWithValue("@WorkOrderID", txtWorkOrderID.Text)
mycommand.Parameters.AddWithValue("@IsDown", chkIsDown.Checked)
Try
mycommand.ExecuteNonQuery()
con.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
con.Close()
End Try
End Sub
I added the line IsDown = @IsDown in the SQL code and mycommand.Parameters.AddWithValue("@IsDown", chkIsDown.Checked) in th
e add with values section.
Thanks