Thread View: borland.public.delphi.database.dotnet
2 messages
2 total messages
Started by Humberto Souza
Tue, 18 Sep 2007 22:38
bdp - dataset - updating rows
Author: Humberto Souza
Date: Tue, 18 Sep 2007 22:38
Date: Tue, 18 Sep 2007 22:38
67 lines
2903 bytes
2903 bytes
Hi,
I have this piece of code, acessing data from a mdb (access) file:
----------
self.bdpSelectCommand1.CommandText := 'select * from tblClientes where
strestado2 = "RJ"';
self.bdpDataAdapter1.SelectCommand := bdpSelectCommand1;
self.bdpDataAdapter1.Fill(DataSet1, 'tblClientes');
qtd_ := self.dataset1.Tables['tblClientes'].Rows.Count;
Response.Write('Rows = : '+inttostr(qtd_)+'<br>');
//showing data
for temp_i := 0 to qtd_ - 1 do begin
Response.Write( 'login :
'+self.dataset1.Tables['tblClientes'].Rows[temp_i].Item['strLogin50'].ToString+'<br>');
Response.Write('Product :
'+self.dataset1.Tables['tblClientes'].Rows[temp_i].Item['produto'].ToString+'<br>');
end;
-----------------------
Works perfectly, shows 8 rows of data (login and product). This is only a
test project. :-)
Now, I have added these folowing lines:
--------------------
//changing data
for temp_i := 0 to qtd_ - 1 do begin
dataset1.Tables['tblClientes'].Rows[temp_i].BeginEdit;
dataset1.Tables['tblClientes'].Rows[temp_i].Item['produto'] :=
'testing new product';
dataset1.Tables['tblClientes'].Rows[temp_i].endEdit;
end;
dataset1.AcceptChanges;
//showing data again
for temp_i := 0 to qtd_ - 1 do begin
Response.Write( 'login :
'+self.dataset1.Tables['tblClientes'].Rows[temp_i].Item['strLogin50'].ToString+'<br>');
Response.Write('Product :
'+self.dataset1.Tables['tblClientes'].Rows[temp_i].Item['produto'].ToString+'<br>');
end;
-------------------
Runnig this project, I can see 16 rows of data.
the first 8 rows, from the original database (access file). The last 8
lines, exatly as should be, all "produto" field, with "testing new product".
Everyting perfect, BUT...
The new data is NOT being saved on main access file, I mean, all the new
data
was lost.
Why? something wrong?
Is there some property to set? A kind of "readonly" = false or something
like that.
Thank you,
Humberto Souza
Re: bdp - dataset - updating rows
Author: Wayne Niddery [TeamB]
Date: Wed, 19 Sep 2007 15:37
Date: Wed, 19 Sep 2007 15:37
14 lines
1618 bytes
1618 bytes
Humberto Souza wrote: Multi-posted and answered elsewhere. Please do not cross-post or multi-post. See the newsgroup guidelines at http://support.codegear.com/newsgroups/guidelines -- Wayne Niddery - Winwright, Inc (www.winwright.ca) "If there is any principle of the Constitution that more imperatively calls for attachment than any other, it is the principle of free thought � not free thought for those who agree with us, but freedom for the thought that we hate." - Oliver Wendell Holmes
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads