开发者

tableadapter.update doesn't work?

I have a problem that driv开发者_StackOverflowes me crazy... I have a local database (.sdf) on my PC en a database on the internet (MySQL), both with same structure. I first load data from the internet in the dataset via the dataadapter and secondly I load some local data in the dataset.

Now I want to store the data from internet also in the local database, I tried it with the Update statement. This has to work, but everytime I run the program (debug) and I went back to the local database (via the database explorer, right click on table, Show Table data...), the internet data has not been saved!

To be clear I do see both data (local en from internet) in my dataGrid1.

What do you think is the problem?

        klantenTableAdapter.ClearBeforeFill = false;

        DigiLocalDataSet dataset = new DigiLocalDataSet();

        string MyConString = "SERVER=server;" +
                    "DATABASE=db;" +
                    "UID=uid;" +
                    "PASSWORD=pass;";
        string sql = "SELECT klantnr, geslacht, voorletters, roepnaam, achternaam, tussenvoegsel, straat, huisnr, subhuisnr, postcode, plaats, telthuis, telmobiel, email, geboortedatum FROM klanten ORDER BY roepnaam";

        MySqlConnection connection = new MySqlConnection(MyConString);

        MySqlCommand cmdSel = new MySqlCommand(sql, connection);

        MySqlDataAdapter da = new MySqlDataAdapter(cmdSel);


        //Fill from internet
        da.Fill(dataset.klanten);


        //Fill from local database
        klantenTableAdapter.Fill(dataset.klanten);

        klantenTableAdapter.Update(dataset.klanten);

        //dataset.AcceptChanges();

        this.DataContext = dataset.klanten.DefaultView;

Thanks in advance!


New to this, but don't you need to call SaveChanges too to commit it to the database?


It seems that de db reference uses a relative path. The Dataset wizard proposes to copy the database to your output directory. However in the Server explorer you are still examining the original database. Could that be it? ;-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜