Why I cannot see the Records Created? See code.

Heavenly

Well-known member
Joined
Aug 22, 2005
Messages
53
Location
Puerto Rico
Programming Experience
1-3
With the code below I’m able to create the records but I’m not able to see it in the DataGridView in real time. (Master-child relationship exist)

The only way to see the records created is by quitting the application and running it again. Then the records appear just fine inside the DataGridView. It is like the DataGridView refuses to perform a refresh.

I also tried this with no luck:
VB.NET:
[FONT='Courier New']        TblStartStopDataGridView.Refresh()[/FONT]
[FONT='Courier New']        TblHoursBindingNavigator.Refresh()[/FONT]

Could anyone tell me what instructions I’m missing from the code below?
VB.NET:
[COLOR=blue][FONT='Courier New']Public[/FONT][/COLOR][FONT='Courier New'] [COLOR=blue]Sub[/COLOR] CreateNewRecordTableStartStop()[/FONT]
[FONT='Courier New'] [/FONT]
[FONT='Courier New']        [COLOR=blue]If[/COLOR] tableHoursUpdating = [COLOR=blue]False[/COLOR] [COLOR=blue]Then[/COLOR][/FONT]
[FONT='Courier New']            tableStartStopUpdating = [COLOR=blue]True[/COLOR][/FONT]
[FONT='Courier New']            [COLOR=blue]Try[/COLOR][/FONT]
[FONT='Courier New']                frmMain.TblStartStopTableAdapter.Insert(m_IDtableStartStop, m_TimePressWasStop, m_TimePressWasStart, m_ReasonPressWasStop, m_PartsMadeBeforeStop, m_PartsMadeDuringStop, m_PartsMadeTotal, m_MinutesPressWasStop, m_Tonnage, m_ShutHeight)[/FONT]
[FONT='Courier New']                [COLOR=blue]My[/COLOR].Computer.Audio.PlaySystemSound(Media.SystemSounds.Hand)[/FONT]
[FONT='Courier New']            [COLOR=blue]Catch[/COLOR] ex [COLOR=blue]As[/COLOR] Exception[/FONT]
[FONT='Courier New']                MessageBox.Show([COLOR=maroon]"There were problems Inserting a new record to the Database Table: START-STOP"[/COLOR], [COLOR=maroon]"Hubbell Press #103 Scada"[/COLOR], MessageBoxButtons.OK, MessageBoxIcon.Information)[/FONT]
[FONT='Courier New']            [COLOR=blue]End[/COLOR] [COLOR=blue]Try[/COLOR][/FONT]
[FONT='Courier New']            tableStartStopUpdating = [COLOR=blue]False[/COLOR][/FONT]
[FONT='Courier New']        [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR][/FONT]
[COLOR=blue][FONT='Courier New'] [/FONT][/COLOR]
[FONT='Courier New']    [COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR][/FONT]
[COLOR=blue][FONT='Courier New'] [/FONT][/COLOR]
[COLOR=blue][FONT='Courier New']End[/FONT][/COLOR][FONT='Courier New'] [COLOR=blue]Module[/COLOR][/FONT]
 
Ok, not 110% on this; but might be worth a shot?

Me.Controls.Item(Me.Controls.IndexOf(Me.TblStartStopDataGridView)).Refresh()
 
Since my code in in a module I retype it like this:
frmMain.Controls.Item(frmMain.Controls.IndexOf(frmMain.TblStartStopDataGridView)).Refresh()

No luck with this either. Any other suggestion?

thanks
 
Any chance you could show some more code, maybe just the declarations?

I'm having a hard time trying to figure out what TblStartStopTableAdapter is. I'm thinking is something you made that inserts into the table and not the datagrid, correct?
 
TblStartStopTableAdapter is generated by VB itself, at least in the 2005 Beta version I'm using.

As soon as you drag a table into the form this is generated as well as the:
DatabaseMainPressDataSet
TblHoursBindingSource
TblHoursTableAdapter
TblHoursBindingNavigator
 
Ouch, I'm sorry; I'm doing all this with 2003 Enterprise Architect. I get the SqlConnection and sqlDataAdapter automatically generated. I should have asked beforehand. Sorry; I'm not going to have what you're looking for. :(
 
I finally got it working by adding this:
VB.NET:
[SIZE=2]frmMain.TblStartStopTableAdapter.Fill(frmMain.DatabaseMainPressDataSet.tblStartStop)
frmMain.TblStartStopDataGridView.Refresh()
[/SIZE]
 
Back
Top