🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.database.dotnet
Article #41

bdp - dataset - updating rows

#41
From: Humberto Souza
Date: Tue, 18 Sep 2007 22:38
67 lines
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
Technical Details
Message-ID: <46f05370$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder3.cambrium.nl!feeder6.cambrium.nl!feed.tweaknews.nl!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,6d35e5cb44541b4,start
X-Google-Attributes: gid1effe6,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Humberto Souza" <hsouza@windnet.psi.br>
Newsgroups: borland.public.delphi.database.dotnet
Subject: bdp - dataset - updating rows
Date: Tue, 18 Sep 2007 19:38:37 -0300
Lines: 73
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
NNTP-Posting-Host: 201.19.114.39
Message-ID: <46f05370$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1190155120 201.19.114.39 (18 Sep 2007 15:38:40 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder3.cambrium.nl!feeder6.cambrium.nl!feed.tweaknews.nl!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail