C# newbie question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a database app in MSVS 2005. I have created the mobile database
and it seems to work with the program. I have inserted a few records for
testing in VS 2005. Those records show up iwhen the program runs in the
emulator.

I created a datagrid form by dragging the grid from the datasources page in
my app. after doing so I noticed a right pointing arrow at the top of the
grid allowing me to let MSVS build my summary and Edit forms. So I did.
However when I add a new horse or horses they seem to be saved to the table
and displayed in the datagrid, but only until I close the datagrid form(not
the application) then when I re open it the records I created while my app
was running in the emulator are no longer there. So I adde this code to the
close of the edit form, but still no luck in saving the records. Can anyone
tell me what Iam doing wrong.

this.horseBindingSource.EndEdit(); this was added by MSVS
I added this below:no errors but data not saved
FB7MobileDBDataSet fb7mobiledataset = new FB7MobileDBDataSet();
FB7MobileDBDataSet.HorseDataTable newhorse =
(FB7MobileDBDataSet.HorseDataTable)
fb7mobiledataset.Horse.GetChanges(DataRowState.Added);

try
{
if (newhorse !=null)
{
horseTableAdapter1.Update(newhorse);
}
fb7mobiledataset.AcceptChanges();
}
catch (System.Exception ex)
{
MessageBox.Show("UpdateFailed");
}
finally
{
if (newhorse != null)
{
newhorse.Dispose();
}
}
 
Hi Jon,

Are you overwriting the database everytime to run the App in debug
mode?
If you have the SDF file in your project it will be overwritten
everytime you deploy the App.

-Neelima
 
HEllo Neelima
The problem isn't that the data isn't saved after I close the application.
I have three forms the main form and the Horse data grid form and the data
entry form. After I insert a new record in the data entry form then close it
to display the data grid form the new record shows up fine. If I close the
datagrid form but NOT the application then re open it it does not show the
new record I just inserted. I can't figure out why.
Thanks Jon
 
Hi Jon,
Are you refreshing your datasource and rebinding when you display the
form again?

_Neelima
 
Back
Top