Board index » delphi » Loading flat file data from ClientDataSet into SQL table

Loading flat file data from ClientDataSet into SQL table

Quote
"Karen McKenzie" <mile.h...@gte.net> wrote in message

news:3eaaf9c8$2@newsgroups.borland.com...

Quote
> Can someone please tell me what I am doing wrong?  I have Delphi  7 and
sql
> 2000.  I want to save my data to use for reports as flat files so 1) Sql
> server doesn't have to be running except when the data is needed and 2) to
> give me way to save the data directly with each project.

> I have written the data to a CDS file using the TClientDataSet.  I need to
> know how to resolve the data read in from the CDS file into the SQL Server
> table.  I am doing the steps below which loads up the ClientData Set but
> never transfers the information to the SQL table.

> 1) I have setup a ADO connection, ADO table, DataSetProvider and
TClientData
> Set componenets.
> 2) My ADO connection points to the SQL database, the ADO table points to
the
> table I want to update in that database.
> 3) The DataSet Provider points to the ADO table and its connection.
> 4) My TClientDataSet points to the DataSetProvider

> I then loadFromFile into the TclientDataSet the contents of my CDS file
and
> call the ApplyUpdates(-1) routine checking for an error (I don't get one).
> I am populating the ClientDataSet but it never get copied into the SQL
> table.

> Sorry if this is a dumb question - I 've tried consulting several books on
> it and I thought I was doing it right.

>      adoTable1.Active := True;
>      cds1.Active := True;
>      cds1.LoadFromFile('C:\JOBS\TESTJOB-PLAN\DB_boards.cds');
>      cds1.ApplyUpdates(-1);

> Any help would be appreciated.

> Karen

I'm just taking a stab at it here, but I think that since none of the
records have actually been changed since they were loaded, no updates need
to be applied. Try creating a second TClientDataSet and shunting its Data
through cds1.AppendData.

Cheers,
  Ignacio

 

Re:Loading flat file data from ClientDataSet into SQL table


Can someone please tell me what I am doing wrong?  I have Delphi  7 and sql
2000.  I want to save my data to use for reports as flat files so 1) Sql
server doesn't have to be running except when the data is needed and 2) to
give me way to save the data directly with each project.

I have written the data to a CDS file using the TClientDataSet.  I need to
know how to resolve the data read in from the CDS file into the SQL Server
table.  I am doing the steps below which loads up the ClientData Set but
never transfers the information to the SQL table.

1) I have setup a ADO connection, ADO table, DataSetProvider and TClientData
Set componenets.
2) My ADO connection points to the SQL database, the ADO table points to the
table I want to update in that database.
3) The DataSet Provider points to the ADO table and its connection.
4) My TClientDataSet points to the DataSetProvider

I then loadFromFile into the TclientDataSet the contents of my CDS file and
call the ApplyUpdates(-1) routine checking for an error (I don't get one).
I am populating the ClientDataSet but it never get copied into the SQL
table.

Sorry if this is a dumb question - I 've tried consulting several books on
it and I thought I was doing it right.

     adoTable1.Active := True;
     cds1.Active := True;
     cds1.LoadFromFile('C:\JOBS\TESTJOB-PLAN\DB_boards.cds');
     cds1.ApplyUpdates(-1);

Any help would be appreciated.

Karen

Re:Loading flat file data from ClientDataSet into SQL table


I suspect that the problem is not in the code in your message but in
the way you created the CDS file. Did you have the LogChanges property
set to Falsef when you added the records to the CDS? Did you call
MergeChangeLog before you saved the CDS?

There do not appear to be any changes in the Delta property to apply.
You can check this be examining the value of ChageCount before you
call ApplyUpdates.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Re:Loading flat file data from ClientDataSet into SQL table


Thanks for the help from both you and Ignacio.  Unfortunately I am either
applying them wrong or these are not working either.  I changed the way I
was writing the CDS to have the logChanges =False and do a merge change log.

  // -----------------------------------------------
  dataMod.dspOutput.DataSet := dataMod.boardDS;
  dataMod.dspOutput.dataSet.Active := True;
  dataMod.cdsOutput.active := True;
  dataMod.cdsOutput.LogChanges := False;
  dataMod.cdsOutput.MergeChangeLog;
  dataMod.cdsOutput.SaveToFile(baseDirName + '\' + 'DB_boards.cds');
  dataMod.dspOutput.dataSet.Active := False;
  dataMod.cdsOutput.active := False;

I also tried using a second tclientDataset and using the appendData.  My
number of changes is always 0.  I've also tried doing the applyupdates
through my dataSetProvider with the same results.

  cds2.AppendData(cds1.Data,True);
  cds2.ApplyUpdates(-1);

Is there anyway to transfer all the records no matter if the Delta is empty?

Thanks again for the help,

Karen

Quote
"Bill Todd" <b...@notthis.dbginc.com> wrote in message

news:pk5mavon74nfethq5l7atu57gp7bapm358@4ax.com...
Quote
> I suspect that the problem is not in the code in your message but in
> the way you created the CDS file. Did you have the LogChanges property
> set to Falsef when you added the records to the CDS? Did you call
> MergeChangeLog before you saved the CDS?

> There do not appear to be any changes in the Delta property to apply.
> You can check this be examining the value of ChageCount before you
> call ApplyUpdates.

> --
> Bill (TeamB)
> (TeamB cannot respond to questions received via email)

Re:Loading flat file data from ClientDataSet into SQL table


On Mon, 28 Apr 2003 14:01:46 -0700, "KMcKenzie" <mile.h...@gte.net>
wrote:

Quote
>Thanks for the help from both you and Ignacio.  Unfortunately I am either
>applying them wrong or these are not working either.  I changed the way I
>was writing the CDS to have the logChanges =False and do a merge change log.

No. In order to save the changes you must have LogChanges := True and
_not_ call MergeChangeLog.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Re:Loading flat file data from ClientDataSet into SQL table


Sorry Bill,  I read your original email as telling me to set those
properties, they were not set before that.  I did finally get it after
writing a test app.  My problem was that I was filling the CDS with
information from another DataSource and that doesn't setup any type of
transaction log of changes.  I changed my code to write directly to the
ClientDataSet and that worked.  Thanks for you help.

Karen

Quote
"Bill Todd" <b...@notthis.dbginc.com> wrote in message

news:eigrav0kh654djag0f3bvp0klj6t78cslk@4ax.com...
Quote

> On Mon, 28 Apr 2003 14:01:46 -0700, "KMcKenzie" <mile.h...@gte.net>
> wrote:

> >Thanks for the help from both you and Ignacio.  Unfortunately I am either
> >applying them wrong or these are not working either.  I changed the way I
> >was writing the CDS to have the logChanges =False and do a merge change
log.

> No. In order to save the changes you must have LogChanges := True and
> _not_ call MergeChangeLog.

> --
> Bill (TeamB)
> (TeamB cannot respond to questions received via email)
>>I suspect that the problem is not in the code in your message but in
>>the way you created the CDS file. Did you have the LogChanges property
>>set to Falsef when you added the records to the CDS? Did you call
>>MergeChangeLog before you saved the CDS?

Other Threads