Click here to Skip to main content
16,004,924 members
Home / Discussions / C#
   

C#

 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
stefan houtz22-Dec-04 2:52
stefan houtz22-Dec-04 2:52 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
Heath Stewart22-Dec-04 6:38
protectorHeath Stewart22-Dec-04 6:38 
GeneralRe: NativeWindow disposing on WM_DESTROY Pin
stefan houtz27-Dec-04 6:01
stefan houtz27-Dec-04 6:01 
GeneralDataTable.ColumnChanged doesn't rais an event after ReadXml() Pin
Dogan Gunay20-Dec-04 0:05
Dogan Gunay20-Dec-04 0:05 
Generalhelp request..., Pin
50519-Dec-04 23:56
50519-Dec-04 23:56 
GeneralRe: help request..., Pin
Colin Angus Mackay20-Dec-04 1:46
Colin Angus Mackay20-Dec-04 1:46 
Generalpropagating datagrid changes in the source database tables Pin
Rashid_Mehmood19-Dec-04 23:24
Rashid_Mehmood19-Dec-04 23:24 
GeneralRe: propagating datagrid changes in the source database tables Pin
Skynyrd20-Dec-04 0:13
Skynyrd20-Dec-04 0:13 
The CommandBuilder will not be able to generate the INSERT, DELETE and UPDATE commands of a multiple table query. U will have to do this manually.

The best way is to create parametrized commands:

As an example, imagine we have the following query: "SELECT T1.A,T1.B, T1.C, T2.D FROM T1,T2 WHERE T2.C=T1.C" being T1.A the primary key of table T1.

We create a dataadapter and fill up our DataSet:
myDataAdapter.Fill(myDataSet,"myTable")

For sake of simplicity, let us say that ur datagrid is bound to the table resulting of this query and shows fields A,B, C and D, but only A, B and C can be edited->thus we only have to propagate changes back to table T1. (Propagating to T2 wouldnt be a problem, but lets keep this as short as posible).

We would create our update, delete and insert commands as follows:

INSERT COMMAND: INSERT INTO T1(A,B,C) VALUES(@A,@B,@C)
Parameters would be mapped to DataColumns A,B and C and RowVersion would be Current.

DELETE COMMAND: DELETE FROM T1 WHERE T1.A=@A
Parameter would be mapped to DataColumn A and RowVersion would be Original.

UPDATE COMMAND: UPDATE T1 SET T1.A=@A_current, T1.B=@B, T1.C=@C WHERE T1.A=@A_original

Parameters would be mapped to DataColumns A,B,C and versions would be Current except the primarykey used in the Where statement which sould be Original.

Once created all commands, we would assign them to our dataadapter and to propagate changes back to the database we would execute:

myAdapter.Update(myDataSet,"myTable");

If your datagrid does not contain all the fields of ur table then pass along the default values in ur sql commands (no need of parameters in those cases).

U could also solve the problem using the dataTable.GetChanges([rowVersion]) method and iterating through all the modified rows and executing the necessary NonQueryCommands using the Update/Insert or Delete commands similar to the shown above depending on the RowState of the current row. This would be a better solution when propagating changes back to multiple tables as you would only have to iterate once throug ur modified rows in order to propagate changes to all afected tables (just run all the nonqueries to all the tables u need on each row).


GeneralRe: propagating datagrid changes in the source database tables Pin
siddlingaSwami20-Dec-04 2:03
susssiddlingaSwami20-Dec-04 2:03 
GeneralReal Time Display Sound WaveForm While Acquiring Pin
Siew Eng19-Dec-04 19:22
Siew Eng19-Dec-04 19:22 
GeneralLate Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Chris Richner19-Dec-04 14:53
Chris Richner19-Dec-04 14:53 
GeneralRe: Late Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Daniel Turini19-Dec-04 17:13
Daniel Turini19-Dec-04 17:13 
GeneralRe: Late Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Chris Richner19-Dec-04 21:51
Chris Richner19-Dec-04 21:51 
GeneralRe: Late Bound Assemblies and SoapFormatter.Deserialize problem... Pin
Chris Richner19-Dec-04 22:25
Chris Richner19-Dec-04 22:25 
Generalhashtable in extended properties Pin
esakal19-Dec-04 14:19
esakal19-Dec-04 14:19 
Generalhashtable in extended properties Pin
esakal19-Dec-04 14:09
esakal19-Dec-04 14:09 
Generaldynamically create multiple controls Pin
fredza19-Dec-04 8:04
fredza19-Dec-04 8:04 
GeneralRe: dynamically create multiple controls Pin
Heath Stewart20-Dec-04 6:28
protectorHeath Stewart20-Dec-04 6:28 
Generalproblem with extender provider Pin
esakal19-Dec-04 4:01
esakal19-Dec-04 4:01 
GeneralRe: problem with extender provider Pin
Colin Angus Mackay19-Dec-04 10:03
Colin Angus Mackay19-Dec-04 10:03 
QuestionHow can i know which form are activated? Pin
anta19-Dec-04 2:29
anta19-Dec-04 2:29 
AnswerRe: How can i know which form are activated? Pin
Heath Stewart20-Dec-04 6:12
protectorHeath Stewart20-Dec-04 6:12 
GeneralFinding dlls Pin
thepersonof19-Dec-04 0:35
thepersonof19-Dec-04 0:35 
GeneralRe: Finding dlls Pin
Colin Angus Mackay19-Dec-04 2:20
Colin Angus Mackay19-Dec-04 2:20 
GeneralRe: Finding dlls Pin
thepersonof19-Dec-04 2:40
thepersonof19-Dec-04 2:40 

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.