I need to generate an XML file from a table with 500.000 rows and 200 columns using Firedac Query and ClientDataSet to record ClientDataSet.SaveToFile.
ClientDataSet.Close;
Query.Sql.Clear;
Query.Sql.Add ("Select * from something");
ClientDataSet.Open;
ClientDataSet.SaveToFile("destination_folder.xml");
But to save the file with SaveToFile is the insufficient memory error.
How could I save this file? There is a way to write to multiple files the ClientDataSet already loaded?
Best regards.
Related
I search many times in Google, SO, and I can't find anything about working with attachment via delphi, so I decide to write this question.
I have a table in .accdb database called Files with those fields:
IDFile PK AutoIncField,
FileName WideStringField,
FilesAttached WideMemoFiled.
How can I save/load files to/from attachment fields using delphi?
Attach files and graphics to the records in your database
The problem here, in delphi the datatype of FilesAttached is TWideMemoField,
when I write ShowMessage(FDTable1FilesAttached.Value); it give just the name of the attachment.
I don't know how to Insert/save files to/from that field using delphi.
It didn't seem that hard to find VBA/C# examples of working with .accdb Attachment fields which should translate fairly easily into Delphi. However, it turned out to be more difficult than I imagined to find something that a) hadn't misunderstood what Attachment fields actually are and b) actually works. Skip to the update section below.
For example, googling
accdb create attachment in vba
gives numerous hits including this one
http://sourcedaddy.com/ms-access/working-with-attachment-fields.html
which you might try as a starting point. It uses MS DAO objects, and includes straightforward code for storing files to Attachment fields and for accessing them. You would need to create a Delphi wrapper unit for the DAO type library, if you don't already have one, using the IDE's Import Type Library
If you would prefer something ADO-based, you might take a look at
https://www.codeproject.com/Questions/843001/Handling-fields-of-Attachment-type-in-MS-Access-us
Update See the function OpenFirstAttachmentAsTempFile in the post by "aspen" (date = 4/11/2012 07:18 am) in this thread
https://access-programmers.co.uk/forums/showthread.php?t=224112&page=2
which shows an apparently successful attempt to extract a file from an attachment field (the thread also contains several other attempts at coding this function).
Note in particular this line
Set rstChild = rstCurrent.Fields(strFieldName).Value ' the .Value for a complex field returns the underlying recordset
which implies that the Value of the attachment field can return a recordset which contains the attached file(s).
Presumably, importing a recent version of the DAO type library into Delphi would allow
a Delphi app to do the same thing, and then one could reverse-engineer the rstChild recordset to see how to populate this field in code. I haven't done that yet, though.
I am creating a temp table in SQL and then adding a new field to it. It seems Firedac is caching the field list for this temp table.
The following code gives me "FDQuery5: Field 'Available' not found."
FDQuery5.Connection := FDConnection1;
FDConnection1.ExecSQL('Select StockNo into #Temp from Stock');
FDQuery5.SQL.Text := 'Select * From #Temp';
FDQuery5.open;
FDConnection1.ExecSQL('Alter Table #Temp add Available Char(1)');
FDQuery5.Close;
FDQuery5.open;
ShowMessage(FDQuery5.FieldByName('Available').AsString);
using XE5 with Firedac.
I have tried Connection.RefreshMetadataCache and I have removed fiMeta from FetchOptions.Cache.
I can get Firedac to recognise the new field if I modify the SQL.Text. This is undesirable as my application will need modifying in quite a few places.
The query remains prepared after you call FDQuery5.Close. That means, it caches also result set structure. To prepare the query replace FDQuery5.Close with FDQuery5.Disconnect.
We are trying to make our app unicode compatible and we are migrating from delphi 2007 to delphi xe2, we came across few issues and need suggestions regarding them
1) one change is to store blob data having unicode strings in database
We store huge xml data as blob in database, but in latest delphi version(xe2), blob is treated as an array of bytes. So what should be done to store blob data in database, have tried like converting Param.AsBlob := WideBytesOf(xml) but that doesn't seem to work.
2) Also we use HyperString from EFD systems for faster string manipulations, but now the unicode version of this library is not available, have compiled the code by changing the ansistring to string and tried to modify few assembly language instructions but was succesful with only few till now, so can any one suggest any alternative for faster string manipulations
I was searching the internet about half a year how to properly put a Blob in a Database and i found one sollution that worked for me perfectly maybe it will help you also:
Image - TcxImage component
MainQuery - TQuery component
MainQueryPicture - its a Blob field in from the database stored in the Query component through the Field Editor
ImagePath - String variable which hold the path to the image file
MainQuery.Edit;
if Image.Picture.Graphic <> nil then //if there is an image loaded to the component
begin
MainQueryPicture.LoadFromFile(ImagePath); //load the image to a blob field
end;
MainQuery.Post; //post any changes to the table
Hope it helps.
I am importing data from dbase into sql and am using the following connection string to read data:
"Provider=Microsoft.Jet.OLEDB.4.0;" + #"Data Source=D:\GS\Source;"
+ "Extended Properties=dbase 5.0;User ID=Admin;Password=;"
The data is read successfully but i find that it includes DELETED rows too. as per dbase, there will be an asterisk as the first character, however we find that neither the file is excluded nor is the asterisk coming as a column.
So how do we load data without this deleted records?
Actually, deleted records are internally marked with a flag and not an "*" that you can query from. However, VFP does have a function to test this deleted flag, but only really applicable if running from a single table and not multiple/joins as it won't know which table you are wondering out... Ex:
select * from YourTable where not deleted()
That being said, VFP has some other "environment" setting commands that MAY work via the OleDB, but I've never actually tried THIS.
Once you have your connection, and it's open, run the following ExecNonQuery might help...
OleDbCommand oCmdTest = new OleDbCommand( "SET DELETED OFF", YourConnection );
OCmdTest.ExecuteNonQuery();
oCmdTest = new OleDbCommand( "Select * from YourTable", YourConnection );
execute it into a data table result set as you are, and you should be good.
One other part. I would not be using the Jet OleDB, but actually using the Microsoft VFP OleDb driver
In dBase after delete command 'pack all' has to be given so that the deleted records are
removed permanently.
If you have access to dBase use the concerned file and then give pack all command
HI,
My Question may be a simple one for you.
I have to import a csv file to my delphi application. This file contains 3 columns and I want to match the columns to one of Dataset( TQuery connected to a Firebird table) and show on a grid.
My Question is, is it possible to use the Csv file as a table, who can access by a SQL query and join to a Db table ?
I have tried with TTable with TableType property as ttASCII. It loads the file.However this loads the contents to a single fields,
ie, Fields[0].asstring gives '11,12,abc.txt'
I want this on different fields
ie,
Fields[0].asstring = '11'
Fields[1].asstring = '12'
Fields[3].asstring = 'abc.txt'
Hope you understand my requirement. Kindly take a look and let me know your thoughts
Thanks and Regards,
Vijesh V.Nair
System Analyst
Vijesh , you have to create a schema definition file to access a txt file from a TTable component, the name of the schema file must the same of the text file but with the SCH extension.
in this link you can found more information about the format of the schema file Using The ASCII Driver With Comma-delimited Files, also you can check the BDE32.HLP file.