bravecobra
14 years agoNew Contributor
How to load the contents of a file from the store into a string.
Hi,
I'm trying to figure out how to load the content of a file into a string in DelphiScript.
The idea is to load a SQL script (that builds my database/ imports sample data) from the stores and then execute it through a ADO connection.
I can execute individual statements, but not whole script.That's what I'm after..
Here's what I've got so far, however TStringlist is not known. (AConnection is a global variable specifying an ADO connection to the server).
procedure ExecuteSQLScript(ASQLScript:string);
var AScript: TStringList;
begin
try
AScript := TStringList.Create;
try
AScript.LoadFromFile(Objects.StoredObject[
<meta http-equiv="content-type" content="text/html; charset=utf-8" />ASQLScript]);
AConnection.Execute_(AScript.Text);
Log.Message(Format('Executed SQL: %s',[
<meta http-equiv="content-type" content="text/html; charset=utf-8" />AScript.Text]));
finally
AScript.free;
end;
except
Log.Error('Execption',ExceptionMessage);
end;
end;
Any ideas?
Tnx.
I'm trying to figure out how to load the content of a file into a string in DelphiScript.
The idea is to load a SQL script (that builds my database/ imports sample data) from the stores and then execute it through a ADO connection.
I can execute individual statements, but not whole script.That's what I'm after..
Here's what I've got so far, however TStringlist is not known. (AConnection is a global variable specifying an ADO connection to the server).
procedure ExecuteSQLScript(ASQLScript:string);
var AScript: TStringList;
begin
try
AScript := TStringList.Create;
try
AScript.LoadFromFile(Objects.StoredObject[
<meta http-equiv="content-type" content="text/html; charset=utf-8" />ASQLScript]);
AConnection.Execute_(AScript.Text);
Log.Message(Format('Executed SQL: %s',[
<meta http-equiv="content-type" content="text/html; charset=utf-8" />AScript.Text]));
finally
AScript.free;
end;
except
Log.Error('Execption',ExceptionMessage);
end;
end;
Any ideas?
Tnx.