HELP, I'm losing faith in me being able to code!
I'm having a application which holds data in different tables.
I'm having multiple forms for putting in the different data.
The forms have datagridviews where the datasources are tables in self-made datasets.
But now i'm totally confused about how to update a table in a dataset in another form when somebody has entered new data in a form.
Please look at the folowing:
I have a form called "Verzendbrief" which has a datagridview "TekVanBedrijvenDataGridView".
The datagridview is filled with data through the folowing code:
CODE
'Get connection string
Dim strconnectionstring As String = My.Settings.DocRegData2ConnectionString
'Create SqlConnection
Dim objconnection As New SqlConnection(strconnectionstring)
'Create SqlCommand
Dim objcommand As New SqlCommand("GetBladnummerNaamTekening2", objconnection)
objcommand.CommandType = CommandType.StoredProcedure
'Set the SelectCommand property of our adapter
objdataAdapter.SelectCommand = objcommand
'Fill the DataSet using the SqlDataAdapter
objdataAdapter.Fill(objdatasetTekeningen, "Tekeningenbedrijven")
TekVanBedrijvenDataGridView.AutoGenerateColumns = True
TekVanBedrijvenDataGridView.DataSource = objdatasetTekeningen.Tables("Tekeningenbedrijven")
With this code the datagridview is filled correctly with the last data.
But now I also have another form for entering new data which also has to be displayed in the above mentioned datagridview.
When the new data is entered how do i update the above mentioned table from a dataset.
I have the folowing code, is this correctly:
CODE
'code where new data is entered in different tables..........
'Renew dataview on frmVerzendbrief because of new data
My.Forms.FrmVerzendbrief.objdataAdapter.Update(My.Forms.FrmVerzendbrief.objdatasetTekeningen, "Tekeningenbedrijven")
My.Forms.FrmVerzendbrief.objdataAdapter.Fill(My.Forms.FrmVerzendbrief.objdatasetTekeningen, "Tekeningenbedrijven")
When i check the
tables the new data is entered correctly.
But in the datagridview first the old data is being displayed and under the old data the new data is being displayed. So the datagridview is showing double data?!?!?! WHY??
Please, please help!! Thnx in advanced