sql - C# SqlCeConnection not updating .sdf file, no data in the file -
i have next code:
string dbfile = "c:\\users\\ralph\\documents\\visual studio 2012\\projects\\workstimes\\workstimes\\database.sdf"; sqlceconnection connection = new sqlceconnection("datasource=" + dbfile); connection.open(); dataset info = new dataset(); datatable dt = new datatable("table2"); dt.columns.add(new datacolumn("id", typeof(int))); dt.columns.add(new datacolumn("name", typeof(string))); data.tables.add(dt); sqlcedataadapter adapter = new sqlcedataadapter("select * [table2]", connection); if (data != null && data.tables.count > 0) { system.diagnostics.debug.writeline("test"); datarow dr = data.tables["table2"].newrow(); dr["id"] = 0; dr["name"] = "jan"; data.tables["table2"].rows.add(dr); data.tables["table2"].rows.add(new object[] { 1, "jan" }); system.diagnostics.debug.writeline(data.tables["table2"].rows.count);//returns 2 adapter.fill(data); adapter.update(data); connection.close(); }
when check database file still empty. why isn't code adding rows database file?
the update command update existing rows - seem seek insert new rows task of .insert method (not .update() ) .... – marc_s 16 mins ago
thanks, looks using wrong things seek rows in database.
c# sql dataset sqlconnection
No comments:
Post a Comment