Updating data

Updating data

Postby Oufti » Sun 21 May 2006 13:55

Hello,

I explain the situation. I do a select from a table
Code: Select all
select * from t_mytable


I put the result in a DataTable via a DataAdapter and some TexTbox linked to the DataTable.

I can change the row with the CurrencyManager.

The "problem" I have. When I change a a field of a record and I save, all the record have the new value, not only the selected one, I use GetUpdateCommand.

To solve the problem, I use a MySQLCommand with an update query with in the where close the id of my record. That's work.

But I have to write a big query with a lot of parameters.

Is it not possible to make an update with in argument a DataRow (just a row) without fill fields one by one ?

Thanks,
Oufti
 
Posts: 24
Joined: Wed 10 May 2006 11:29

Postby Alexey » Mon 22 May 2006 06:44

all the record have the new value, not only the selected one
What do you mean? A record has some fields and all of them get updated with new values? Please specify. Where these values came from?
Send us small test project if possible to reproduce the problem; it is
desirable to use 'test' schema objects, otherwise include definition of
your own database objects. Do not use third party components.[/quote]
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby Oufti » Mon 22 May 2006 06:54

Alexey wrote:What do you mean? A record has some fields and all of them get updated with new values? Please specify. Where these values came from?


The data are in DataTable. Is it not possible to update one record (or more) without do an update query like this :

Code: Select all
UPDATE t_mytable SET
field1 = 'data_from_Datarow_1',
field2 = 'data_from_Datarow_2'


Imagine where there are 50 or more fields ....

But do something like in ORACLE PL/SQL, give in argument to query the DataRow and the query will update all the field for this record.

Thanks,
Oufti
 
Posts: 24
Joined: Wed 10 May 2006 11:29

Postby Alexey » Mon 22 May 2006 08:13

There is an UpdateCommand property in MySqlDataTable component which you can change however you like. (The update statement is initially created when you configure your MySqlDataTable.)
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby Oufti » Mon 22 May 2006 15:07

Alexey wrote:There is an UpdateCommand property in MySqlDataTable component which you can change however you like. (The update statement is initially created when you configure your MySqlDataTable.)


Yes, I know that. But I'd like pass in argument to a function to make an update, a DataRow of a DataTable for the specific record (DataRow), like this I won't have to write un SqlCommand with an update with a lot of fields.

Thanks,
Oufti
 
Posts: 24
Joined: Wed 10 May 2006 11:29

Postby Alexey » Tue 23 May 2006 06:09

Please describe your function, table, specify what you want to perform.
Is it not possible to update one record (or more) without do an update query like this :
Code:
UPDATE t_mytable SET
field1 = 'data_from_Datarow_1',
field2 = 'data_from_Datarow_2'

It is possible if specify some criteria in WHERE clause.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby Oufti » Tue 23 May 2006 06:31

Alexey wrote:It is possible if specify some criteria in WHERE clause.


Really ? :wink:

Of course, I know it's possible. I'm trying an another solution, to do what I want.

Thanks,
Oufti
 
Posts: 24
Joined: Wed 10 May 2006 11:29

Postby Alexey » Tue 23 May 2006 06:39

What you want is unclear for us. Please specify. And we will do our best.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for MySQL