c# - DataSet Saving Changes -
i have visual studio c# forms project. in project smartcon.mdf. can see below dataset created.
for reason data not saving. when add player dataset code follows.
smartcondataset.playersrow newplayer = mydata.players.newplayersrow(); newplayer.id = guid.newguid().tostring(); newplayer.guid = newguid; newplayer.firstseen = datetime.now; newplayer.kills = 0; newplayer.deaths = 0; newplayer.totalscore = 0; mydata.players.addplayersrow(newplayer); smartcondataset.namesrow newname = mydata.names.newnamesrow(); newname.id = guid.newguid().tostring(); newname.name = name; newname.playerid = newplayer.guid; newname.active = 1; mydata.names.addnamesrow(newname); //update database mydata.acceptchanges();
why isn't data saving database?
update: can confirm data getting added dataset, not transfering database.
update 2: may need connection string database????
update 3:
var playertableadapter = new smartcondatasettableadapters.playerstableadapter(); smartcondataset.playersrow newplayer = mydata.players.newplayersrow(); newplayer.id = guid.newguid().tostring(); newplayer.guid = newguid; newplayer.firstseen = datetime.now; newplayer.kills = 0; newplayer.deaths = 0; newplayer.totalscore = 0; playertableadapter.insert(newplayer.guid, newplayer.kills, newplayer.deaths, newplayer.id, newplayer.firstseen, newplayer.firstseen, 0); //add players name name table var namestableadapter = new smartcondatasettableadapters.namestableadapter(); smartcondataset.namesrow newname = mydata.names.newnamesrow(); newname.id = guid.newguid().tostring(); newname.name = name; newname.playerid = newplayer.id; newname.active = 1; var result = namestableadapter.insert(newname.id, newname.playerid, newname.name, 1);
from research, dataset cannot directly make changed database. see thread...
however database still not being updated new rows.
update 4: according link in update 3, connection string wrong well. works great, however, connection string path on computer rather relative path. if place on else computer wont work file path not same mine.
the database not updated using these methods. need use tableadapter.insert update etc
Comments
Post a Comment