Dataset Declaration again ... CJ listening? Anyone else

J

Jeff Brown

OK i have came to the conclusion that since this app will be run on multiple computers that loading a complete database and then updating on exit is a moot point. I have tried several ideas submitted, but i am unable to get one of them to work completely. Here is the code i had before i realized that when i filled the dataset in the form load procedure that it would "ruin, replace, mess up" the dataset named the same thing on the other form. Below is my Update, Add, Edit and Cancel code and an exerpt from the form load which like i say, worked fine before i realized i would have to change where i declared my datasets. Do i need to programmtically code my datasets in a module, (someone else mentioned that) and if so how? so that every time a childform is loaded or made active it has an updated set of data? and i do not have several datasets containing the same data? The way i was currently headed i would have had a trailers dataset containing all trailer info and a seperate dataset containing only trailer numbers for use in another form. I have been reading all day, and am still just about where i was earlier.
I tried this and got syntax errors.
childs form class
dim tform as mdiMainForm (whatever the type is)
tForm = me.mdiParent
me.dsWhatever.merge (tForm.dsName1)

"PLEASE NOTE: The parts that were commented out worked great until i realized they wouldn't work... uh.. well you know what i mean.
Form Load
Private Const cblnEditing As Boolean = True
Private Const cblnNotEditing As Boolean = False
' I used to fill them this way beacuse they were created on the child form, but that doesn't work since each child form has at least 2 of these
' So I asked and was given the right idea and think i have a pretty good understanding now, but i still do not know where or how to declare my 'datasets any differently so that each form can access them and be updated when the active child changes.
odbdaTrailers.fill(dsTrailers1)
odbdaTrucks.fill(dsTrucks1)
odbdaDrivers.fill(dsDrivers1)
.....ETC ETC ETC
End Form Load

Private Sub AddData()
' Set the menu items to indicate that a record is being edited.
Call EditState(cblnEditing)
' Add a new record.
'Worked the whole way but not since i need the portions of the same dataset across multiple forms
'Me.BindingContext(DsTrailers1, "equipTrailers").AddNew()
End Sub

Private Sub EditData()
Call EditState(cblnEditing)
End Sub

Private Sub CancelData()
' Update the menu items to not editing.
Call EditState(cblnNotEditing)
'Me.BindingContext(DsTrailers1, "EquipTrailers").CancelCurrentEdit()
End Sub

Private Sub UpdateData()
' Temporary DataSets to store the inserted or modified row.
Dim pdsInsertedRows, pdsModifiedRows As DataSet
' Set the menu items to editing.
Call EditState(cblnNotEditing)

' End editing on the current record.
' Me.BindingContext(DsTrailers1, "equiptrailers").EndCurrentEdit()

' Copy the DataSets by getting added/modified records from original DataSet.
'pdsInsertedRows = DsTrailers1.GetChanges(DataRowState.Added)
'pdsModifiedRows = DsTrailers1.GetChanges(DataRowState.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
' odbdaTrailers.Update(pdsInsertedRows)
End If

' Check to see if there is a modified row. If there is update dataset
If Not pdsModifiedRows Is Nothing Then
' odbdaTrailers.Update(pdsModifiedRows)
End If

' Synchronize the database to dataset
' DsTrailers1.AcceptChanges()
End Sub
 
C

CJ Taylor

Jeff,

I do'nt think I understand what your asking here... your code is alittle vague to answer a question on it. I apologize.

You have a lot of commented out stuff that shoulnd't necessarily be commented out.


Thanks,
CJ
OK i have came to the conclusion that since this app will be run on multiple computers that loading a complete database and then updating on exit is a moot point. I have tried several ideas submitted, but i am unable to get one of them to work completely. Here is the code i had before i realized that when i filled the dataset in the form load procedure that it would "ruin, replace, mess up" the dataset named the same thing on the other form. Below is my Update, Add, Edit and Cancel code and an exerpt from the form load which like i say, worked fine before i realized i would have to change where i declared my datasets. Do i need to programmtically code my datasets in a module, (someone else mentioned that) and if so how? so that every time a childform is loaded or made active it has an updated set of data? and i do not have several datasets containing the same data? The way i was currently headed i would have had a trailers dataset containing all trailer info and a seperate dataset containing only trailer numbers for use in another form. I have been reading all day, and am still just about where i was earlier.
I tried this and got syntax errors.
childs form class
dim tform as mdiMainForm (whatever the type is)
tForm = me.mdiParent
me.dsWhatever.merge (tForm.dsName1)

"PLEASE NOTE: The parts that were commented out worked great until i realized they wouldn't work... uh.. well you know what i mean.
Form Load
Private Const cblnEditing As Boolean = True
Private Const cblnNotEditing As Boolean = False
' I used to fill them this way beacuse they were created on the child form, but that doesn't work since each child form has at least 2 of these
' So I asked and was given the right idea and think i have a pretty good understanding now, but i still do not know where or how to declare my 'datasets any differently so that each form can access them and be updated when the active child changes.
odbdaTrailers.fill(dsTrailers1)
odbdaTrucks.fill(dsTrucks1)
odbdaDrivers.fill(dsDrivers1)
....ETC ETC ETC
End Form Load

Private Sub AddData()
' Set the menu items to indicate that a record is being edited.
Call EditState(cblnEditing)
' Add a new record.
'Worked the whole way but not since i need the portions of the same dataset across multiple forms
'Me.BindingContext(DsTrailers1, "equipTrailers").AddNew()
End Sub

Private Sub EditData()
Call EditState(cblnEditing)
End Sub

Private Sub CancelData()
' Update the menu items to not editing.
Call EditState(cblnNotEditing)
'Me.BindingContext(DsTrailers1, "EquipTrailers").CancelCurrentEdit()
End Sub

Private Sub UpdateData()
' Temporary DataSets to store the inserted or modified row.
Dim pdsInsertedRows, pdsModifiedRows As DataSet
' Set the menu items to editing.
Call EditState(cblnNotEditing)

' End editing on the current record.
' Me.BindingContext(DsTrailers1, "equiptrailers").EndCurrentEdit()

' Copy the DataSets by getting added/modified records from original DataSet.
'pdsInsertedRows = DsTrailers1.GetChanges(DataRowState.Added)
'pdsModifiedRows = DsTrailers1.GetChanges(DataRowState.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
' odbdaTrailers.Update(pdsInsertedRows)
End If

' Check to see if there is a modified row. If there is update dataset
If Not pdsModifiedRows Is Nothing Then
' odbdaTrailers.Update(pdsModifiedRows)
End If

' Synchronize the database to dataset
' DsTrailers1.AcceptChanges()
End Sub
 
J

Jeff Brown

Yeah i commented it out because i had removed the ds's contained in the project and started over in order to quit getting errors(just commented it out so i wouldn't have to retype if i used the same names), I am going to get another book so that maybe if i cannot figure it out at least i will be able to ask my question correctly. If you have a Yahoo mail account you don't use i can send the whole project to you for you to take a look at and then maybe you will understand what i do not know how to ask. hehehe. Basically, dsTrailers1 gets filled on form1 and needs certain fields and then on form2 dsTrailers1 gets filled with different fields, but the problem lies in where i declare them and how to access them because when i load form1 and do something it works fine, but then if i load form2 i get an error because the dataadapter on each form redefined the dsTrailers.xsd and eliminated needed fields, maybe i should work with dataviews based on the entire "Trailer" table , hence trailers.xsd wouldn't get redifined . Gone to books a million , hehehe, give me a week and i will at least know how to ask my question if i still have one. Thanks for everyones help, sorry to seem so "leechy", but i try to contibute where i can.

Thanks,
Jeff
Jeff,

I do'nt think I understand what your asking here... your code is alittle vague to answer a question on it. I apologize.

You have a lot of commented out stuff that shoulnd't necessarily be commented out.


Thanks,
CJ
OK i have came to the conclusion that since this app will be run on multiple computers that loading a complete database and then updating on exit is a moot point. I have tried several ideas submitted, but i am unable to get one of them to work completely. Here is the code i had before i realized that when i filled the dataset in the form load procedure that it would "ruin, replace, mess up" the dataset named the same thing on the other form. Below is my Update, Add, Edit and Cancel code and an exerpt from the form load which like i say, worked fine before i realized i would have to change where i declared my datasets. Do i need to programmtically code my datasets in a module, (someone else mentioned that) and if so how? so that every time a childform is loaded or made active it has an updated set of data? and i do not have several datasets containing the same data? The way i was currently headed i would have had a trailers dataset containing all trailer info and a seperate dataset containing only trailer numbers for use in another form. I have been reading all day, and am still just about where i was earlier.
I tried this and got syntax errors.
childs form class
dim tform as mdiMainForm (whatever the type is)
tForm = me.mdiParent
me.dsWhatever.merge (tForm.dsName1)

"PLEASE NOTE: The parts that were commented out worked great until i realized they wouldn't work... uh.. well you know what i mean.
Form Load
Private Const cblnEditing As Boolean = True
Private Const cblnNotEditing As Boolean = False
' I used to fill them this way beacuse they were created on the child form, but that doesn't work since each child form has at least 2 of these
' So I asked and was given the right idea and think i have a pretty good understanding now, but i still do not know where or how to declare my 'datasets any differently so that each form can access them and be updated when the active child changes.
odbdaTrailers.fill(dsTrailers1)
odbdaTrucks.fill(dsTrucks1)
odbdaDrivers.fill(dsDrivers1)
....ETC ETC ETC
End Form Load

Private Sub AddData()
' Set the menu items to indicate that a record is being edited.
Call EditState(cblnEditing)
' Add a new record.
'Worked the whole way but not since i need the portions of the same dataset across multiple forms
'Me.BindingContext(DsTrailers1, "equipTrailers").AddNew()
End Sub

Private Sub EditData()
Call EditState(cblnEditing)
End Sub

Private Sub CancelData()
' Update the menu items to not editing.
Call EditState(cblnNotEditing)
'Me.BindingContext(DsTrailers1, "EquipTrailers").CancelCurrentEdit()
End Sub

Private Sub UpdateData()
' Temporary DataSets to store the inserted or modified row.
Dim pdsInsertedRows, pdsModifiedRows As DataSet
' Set the menu items to editing.
Call EditState(cblnNotEditing)

' End editing on the current record.
' Me.BindingContext(DsTrailers1, "equiptrailers").EndCurrentEdit()

' Copy the DataSets by getting added/modified records from original DataSet.
'pdsInsertedRows = DsTrailers1.GetChanges(DataRowState.Added)
'pdsModifiedRows = DsTrailers1.GetChanges(DataRowState.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
' odbdaTrailers.Update(pdsInsertedRows)
End If

' Check to see if there is a modified row. If there is update dataset
If Not pdsModifiedRows Is Nothing Then
' odbdaTrailers.Update(pdsModifiedRows)
End If

' Synchronize the database to dataset
' DsTrailers1.AcceptChanges()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top