Hello everyone,
I am working on a MDI Application to track machine maintenance schedule and I have run into a problem with a datagridview.
When i launch my application (mdiMain) the load event triggers the opening of a form (frmTaskWork) with a datagridview. The load event of the frmTaskWork form calls the sub routine filldatagrid() which checks to see if the dataset (dsTasks) returned from my Task Class has any rows. If there are rows the datagrid is populated and if there are no rows the form is closed.
Here is the code for my Sub routine filldatagrid
From this form (frmTaskWork) the user can click on a row in the datagridview which opens a form to allow the user to complete a work order for the selected maintenance item. The form (frmNewJob) that opens is populated with relevant data and allows the user to enter any notes. Once the submit button is click an array is filled with the data and passed to my Jobs class where it is inserted into my DB table and other tables are update. This part work as it should but the datagridview isn't being update with the new changes even though I am calling the filldatagrid sub routine.
Here is the the console output from before and after the insert.
As you can see from the output the dataset is being updated with the correct data but the datagridview isn't being updated. I'm not sure what the problem is or how to fix it.
I hope my explanation isn't too confusing and thanks in advance for any help.
-Fred
I am working on a MDI Application to track machine maintenance schedule and I have run into a problem with a datagridview.
When i launch my application (mdiMain) the load event triggers the opening of a form (frmTaskWork) with a datagridview. The load event of the frmTaskWork form calls the sub routine filldatagrid() which checks to see if the dataset (dsTasks) returned from my Task Class has any rows. If there are rows the datagrid is populated and if there are no rows the form is closed.
Here is the code for my Sub routine filldatagrid
VB.NET:
Public Sub fillDatagrid()
dsTasks.Clear()
dsTasks = task.getCurrentTask()
With bs
.ResetBindings(False)
.DataSource = dsTasks.Tables("TaskInfoList")
End With
If dsTasks.Tables("TaskInfoList").Rows.Count > 0 Then
dgMaintenanceTask.DataSource = bs
dgMaintenanceTask.Refresh()
hideColumns()
Else
Me.Close()
End If
Console.WriteLine("")
Console.WriteLine("------------Current Data in Dataset------------")
For Each row As DataRow In dsTasks.Tables("TaskInfoList").Rows
Try
Console.WriteLine("Task Name: " & row.Item("TaskName") & " | " & _
"Last Completed: " & row.Item("LastCompleted") & " | " & _
"Machine: " & row.Item("EquipmentName"))
Catch ex As Exception
MsgBox(ex.Message.ToString())
End Try
Next
End Sub
From this form (frmTaskWork) the user can click on a row in the datagridview which opens a form to allow the user to complete a work order for the selected maintenance item. The form (frmNewJob) that opens is populated with relevant data and allows the user to enter any notes. Once the submit button is click an array is filled with the data and passed to my Jobs class where it is inserted into my DB table and other tables are update. This part work as it should but the datagridview isn't being update with the new changes even though I am calling the filldatagrid sub routine.
Here is the the console output from before and after the insert.
VB.NET:
Connection Open
Connection Closed
->Before Work Order Insert
------------Current Data in Dataset------------
Task Name: Change Filter | Last Completed: 3/5/2011 | Machine: Portable Chiller #1
Task Name: Clean Filter | Last Completed: 3/5/2011 | Machine: Main Dryer
Task Name: Clean Filters | Last Completed: 3/5/2011 | Machine: Blender
Task Name: Clean Filter | Last Completed: 3/5/2011 | Machine: Hopper Dryer #1
Task Name: Check for leaks | Last Completed: 3/5/2011 | Machine: Temp Controller #1
Task Name: Change HP Filter | Last Completed: 3/5/2011 | Machine: KM #1
Selected Row: 1
Task ID: 1
getJobList Connection Open
getJobList Connection Closed
New Id: 1
Connection Open
Connection Closed
-> After work order insert
------------Current Data in Dataset------------
Task Name: Clean Filter | Last Completed: 3/5/2011 | Machine: Main Dryer
Task Name: Clean Filters | Last Completed: 3/5/2011 | Machine: Blender
Task Name: Clean Filter | Last Completed: 3/5/2011 | Machine: Hopper Dryer #1
Task Name: Check for leaks | Last Completed: 3/5/2011 | Machine: Temp Controller #1
Task Name: Change HP Filter | Last Completed: 3/5/2011 | Machine: KM #1
As you can see from the output the dataset is being updated with the correct data but the datagridview isn't being updated. I'm not sure what the problem is or how to fix it.
I hope my explanation isn't too confusing and thanks in advance for any help.
-Fred