Click here to Skip to main content
15,917,176 members
Home / Discussions / Database
   

Database

 
Questionhow to get latest usage time per pc Pin
batmanAgen2-Mar-06 3:47
batmanAgen2-Mar-06 3:47 
AnswerRe: how to get latest usage time per pc Pin
kageorge2-Mar-06 23:38
kageorge2-Mar-06 23:38 
GeneralRe: how to get latest usage time per pc Pin
batmanAgen3-Mar-06 0:00
batmanAgen3-Mar-06 0:00 
QuestionQuery About NULL Pin
Subramaniam s.V.2-Mar-06 1:06
Subramaniam s.V.2-Mar-06 1:06 
AnswerRe: Query About NULL Pin
Dave Mavin2-Mar-06 1:33
Dave Mavin2-Mar-06 1:33 
AnswerRe: Query About NULL Pin
Dave Mavin2-Mar-06 1:52
Dave Mavin2-Mar-06 1:52 
QuestionTo pass parameters in Data Access Application Block.. Pin
MudkiSekhon2-Mar-06 1:02
MudkiSekhon2-Mar-06 1:02 
QuestionTier Development : DataSets Pin
Dave Mavin1-Mar-06 23:52
Dave Mavin1-Mar-06 23:52 
Hi,

I am new to .NET and trying to understand the concept of the DataSet, so if I am talking rubbish please excuse my ignorance.Sigh | :sigh:

I believe one usage for the DataSet cab be to transport changes using the GetChanges() method to data services, hence limiting the amount of data in this transfer via a new DataSet.

In my simple example I use the Northwind database from SQL server to populate a DataSet and stored procedures to perform the required update commands. If I use these they work fine.

DataSet changedDataSet = new DataSet(); // Transport DataSet
DataSet commonDataSet = new DataSet(); // Working DataSet
SqlDataAdapter commonDataAdapter = new SqlDataAdapter ( ) ;
commonDataAdapter.SelectCommand = GenerateSelectCommand ( Sqlconn ) ;
commonDataAdapter.InsertCommand = GenerateInsertCommand ( Sqlconn ) ;
commonDataAdapter.UpdateCommand = GenerateUpdateCommand ( Sqlconn ) ;
commonDataAdapter.DeleteCommand = GenerateDeleteCommand ( Sqlconn ) ;
commonDataAdapter.Fill(commonDataSet,"Region");

At this point the commonDataSet is filled will all the records I require from the Region database table using a stored procedure for the select. When reviewing the data I get the following, this also indicates the RowState. I realise that the DataSet is a cached data/schema and AcceptChanges would commit and the Data Adapter Update() would fire the stored procedure updates to the DB based on RowState.

1 My Record To Edit. Unchanged
2 Western Unchanged
3 Northern Unchanged
4 Southern Unchanged
5 NorthWest Unchanged
6 NorthWest Unchanged

Now I perform some simple operations on the records as follows.

// Add new record
DataRow aRecord = commonDataSet.Tables["Region"].Rows.Add(new object [] {999, "NorthWest"});

// Edit record 1
aRecord = commonDataSet.Tables["Region"].Rows[0];
aRecord.BeginEdit();
aRecord["RegionDescription"] = "Edit this.";
aRecord.EndEdit();

// Delete record 4
aRecord = commonDataSet.Tables["Region"].Rows[3];
aRecord.Delete();

This results in the following. I have simply dumped the text out if the record is deleted, as I cannot access fields.

1 Edit this. Modified
2 Western Unchanged
3 Northern Unchanged
Row Deleted
5 NorthWest Unchanged
6 NorthWest Unchanged
999 NorthWest Added

I now trap the changes into a new DataSet as follows. I could use the override methods to select what I want but here I take all.

changedDataSet = commonDataSet.GetChanges();

//changedDataSet = commonDataSet.GetChanges(DataRowState.Modified | //DataRowState.Added); - Could do this to overload.

Now I look at the changes (changedDataSet) as follows.

1 Edit this. Modified
999 NorthWest Added
Row Deleted

Now my question is if I transport this DataSet to a data service component, which is responsible for updating the records on the central DB, how do I handle the deleted record as I have no field information such as Primary key ID etc? WTF | :WTF:

Any help would be appreciated.WTF | :WTF:

AnswerRe: Tier Development : DataSets Pin
cbhkenshin_home2-Mar-06 8:06
cbhkenshin_home2-Mar-06 8:06 
GeneralRe: Tier Development : DataSets Pin
Dave Mavin3-Mar-06 0:21
Dave Mavin3-Mar-06 0:21 
GeneralRe: Tier Development : DataSets Pin
Dave Mavin3-Mar-06 3:51
Dave Mavin3-Mar-06 3:51 
QuestionJoin SELECT statements? Pin
myNameIsRon1-Mar-06 20:41
myNameIsRon1-Mar-06 20:41 
AnswerRe: Join SELECT statements? Pin
Colin Angus Mackay1-Mar-06 21:04
Colin Angus Mackay1-Mar-06 21:04 
GeneralRe: Join SELECT statements? Pin
myNameIsRon3-Mar-06 5:33
myNameIsRon3-Mar-06 5:33 
QuestionCreate index using ADO.NET??? Pin
wasife1-Mar-06 17:16
wasife1-Mar-06 17:16 
AnswerRe: Create index using ADO.NET??? Pin
Colin Angus Mackay1-Mar-06 20:43
Colin Angus Mackay1-Mar-06 20:43 
GeneralRe: Create index using ADO.NET??? Pin
Paul Conrad2-Mar-06 5:35
professionalPaul Conrad2-Mar-06 5:35 
QuestionSQL Profiler results question Pin
theJazzyBrain28-Feb-06 23:19
theJazzyBrain28-Feb-06 23:19 
QuestionArithmetic overflow error converting expression to data type int. Pin
japel28-Feb-06 13:39
japel28-Feb-06 13:39 
AnswerRe: Arithmetic overflow error converting expression to data type int. Pin
WoutL1-Mar-06 0:37
WoutL1-Mar-06 0:37 
GeneralRe: Arithmetic overflow error converting expression to data type int. Pin
Le centriste1-Mar-06 1:53
Le centriste1-Mar-06 1:53 
AnswerRe: Arithmetic overflow error converting expression to data type int. Pin
japel1-Mar-06 12:39
japel1-Mar-06 12:39 
Questionnewbie SQL question Pin
Mundo Cani28-Feb-06 10:57
Mundo Cani28-Feb-06 10:57 
AnswerRe: newbie SQL question Pin
Al Ortega28-Feb-06 11:14
Al Ortega28-Feb-06 11:14 
AnswerRe: newbie SQL question Pin
Colin Angus Mackay1-Mar-06 1:25
Colin Angus Mackay1-Mar-06 1:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.