John G3

New to Mobile Development and I am getting my feet wet with the following tutorial: http://msdn.microsoft.com/msdntv/episode.aspx xml=episodes/en/20060831MobileRB/manifest.xml

I follow the tutorial exactly, but the data I edit through the Edit Dialog Form is not saved to the SQL Server table even though all of the edits appear in the datagrid. They never make it back into the table.

Any help would be appreciated.

Thanks!



Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

Ilya Tumanov

Usual reasons:

1. You did not save your changes ¨C make sure to call DataAdapter.Update() or TableAdapter.Update() if you¡¯re using designers.

2. You called AcceptChanges() which marks all data unchanged so DataAdapter can¡¯t find data to be updated ¨C don¡¯t call it, DataAdapter would do it as soon as data is updated.

3. You¡¯re redeploying your database overwriting changed one with original copy on your desktop ¨C change deployment options so changed file won¡¯t be overwritten.






Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

Zero Dai - MSFT

Dear john,

If you are using BindingSource between Sql ce table and datagrid control, check if the EndEdit Method is called after you edit data. If you are binding sql ce table as datasource directly to datagrid control, check if the update method is called. It is also good for you to set a breakpoint and step into your method to see what the issue is.

Moreover, I also keep on studying while working.

Rome is not build in one day. If you have question, feel free to sharing it here. Let's discuss it.

Regards,

Zero Dai - MSFT






Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

John G3

Ilya,

Thanks for replying on my issue. In response to your points:

(1) I did a sample project based on the tutorial where on the Main Form I have a datagrid and a button. The Edit and View forms were auto generated as in the MSFT tutorial I referenced. In the button click event on the data grid form I have the following code:

private void button1_Click(object sender, EventArgs e)

{

this.traineesBindingSource.EndEdit();

this.traineesTableAdapter.Update(this.fitnessJournalDataSet.Trainees);

this.Close();

}

When the edit form closes I see my insert or edit in the datagrid on the main form, but once closes do not see it in Database.

(2) I checked and I did not add any code to call AcceptChanges() nor did I find it any where in the project.

(3) I have the option to redeploy the database only when newer. Also, I check the database file timestamp from the DEBUG folder immediately after closing the Emulator and it never changes.

Please let me know if you have any additional thoughts as I am still having the same issue.

Thanks,

John.

this.traineesTableAdapter.Update(this.fitnessJournalDataSet.Trainees);





Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

John G3

Thanks for taking time to respond to my issue. I made sure that the following code was being executed but still no post to the database:

private void button1_Click(object sender, EventArgs e)

{

this.traineesBindingSource.EndEdit();

this.traineesTableAdapter.Update(this.fitnessJournalDataSet.Trainees);

this.Close();

}

Any additional thoughts you might have for me would be greatly appreciated.

Thanks,

John.





Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

Ilya Tumanov

John, from time to time something like this happens to all of us - you edit source code, but compiler won't pick up the changes, you change database, but no changes are saved and so on. If you can't find reasonable explanation it usually something silly like changing wrong file or looking in a wrong folder - I'm sure you know what I'm talking about.

Again, that works on probably hundreds of thousands devices. Can't find the problem - go ahead and add diagnostics and eliminate potential reasons. For example, don't use VS to launch your application, use file explorer -that would guarantee file is not overwritten. Open database in query analyzer, check if you can see new records. Write a simple application which don't have data grid, may be no UI at all, just loads data from SQL CE, changed record and saves it back, see if that works. You can even close connection in the same application after database has been updated, open it again, load data and see if changes are present.






Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

Zero Dai - MSFT

Dear john,

Try to check the database file on your device/emulator with anaylizer tool, not the one under debug folder. Your code is right and the data in database should be updated already.

Sincerely,

Zero Dai - MSFT






Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

John G3

Dear Zero Dai,

I am running in the emulator and found the Query Analyzer tool, but can not connect to my database. I typed the filename "journal.sdf" and hit connect it comes back with an error it cannot find the file. I also, then tried using the search application function to find the file somewhere in the emulator and the search tool does not come back with any files matching my database file.

I guess how do I find the database file on the emulator inside of VS05

Any additional help would be appreciated.

Thanks,

John Gerold.





Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

Ilya Tumanov

You have to provide full path to the database, not just a file name. If you're using VS to deploy the file, it's in the same folder as your application.

Application is usually deployed to \Program Files\<Application name> unless you¡¯ve changed that in project properties.

Use file explorer on emulator to find it, then click on a file and QA should open it.






Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

Kunis Alexander

Hello John,

Can you please inform me/us if you solved the problem
I'm experiensing the very similar problem with only difference that I'm trying to use an Access database instead of SQL Server.
Therefore I'm very interested if and how you solved the problem.

Thanks in advance,
Alexander.




Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

John G3

Ilya and Zero,

Thanks to both for your help and patience. As you both suspected, I was looking in the wrong folder, as it turned out the changes where reflected in the database on the emulator inside of the folder \Program Files\My App\

John.





Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

John G3

Alexander,

See my post above, as I did get it resolved with the posted replies from Ilya and Zero. Initially, I was missing the table adapter update, and then I was looking at the wrong database for my changes(ie on my laptop) when they were in fact posted inside of the emulator.

John.





Re: Smart Devices General SQL Server Compact table not getting data edits made in datagrid from vs05 c#

Kunis Alexander

Thank you, John,

I have took a look and found that I also examined incorrect database.
The Studio copied the mdb file from the project's folder to the folder with the final exe during each compilation. Therefore the file with the changes was overwriten on each compilation.

Sasha.