gutian
asked on
how can i save a excel file to sqlserver and display it on web
I have stored a doc file into a mssql table with image type
,then I want to display on internetexplorer by asp .
how can I do
,then I want to display on internetexplorer by asp .
how can I do
to be more specific,
i need to know the database and
the connection-type(bde,odbc,a do,other)
i need to know the database and
the connection-type(bde,odbc,a
ASKER
I used Ado
I have used TAdoblobstream,it work not well
I have used TAdoblobstream,it work not well
ASKER
and I want to auto finish the work ,user look the file use
internetexplorer
internetexplorer
ASKER
kretzschmar :
Can you tell me all ways.Thank you very mach
!!!!!!!!!!!!!!!!
Can you tell me all ways.Thank you very mach
!!!!!!!!!!!!!!!!
just give more information ok?
if u want to show,I think u can use the assignfile do view the file,right?
if u want to show,I think u can use the assignfile do view the file,right?
ASKER
Sorry,the follow is my source code,if I stored the text file ,it work well.but when I stored doc or xsl,it will be
wrong.
and Iwant to know how can I load the file content use Asp on internetexplorer.
thanks
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, Db, ADODB, StdCtrls,dbtables;
type
TForm1 = class(TForm)
Button1: TButton;
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
OpenDialog1: TOpenDialog;
Button2: TButton;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
function LoadFromBlob(const AField: TField; const Stream: TStream): boolean;
function SaveToBlob(const Stream: TStream; const AField: TField): boolean;
function StoreFile: boolean;
function LoadFile: boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender : TObject);
begin
try
ADOQuery1.Edit;
StoreFile;
ADOQuery1.Post;
except
ADOQuery1.Cancel;
end;
end;
procedure TForm1.Button2Click(Sender : TObject);
begin
LoadFile;
end;
function TForm1.LoadFile: boolean;
var
FS: TFileStream;
begin
FS := TFileStream.Create(getcurr entdir+'\T est2.doc', fmCreate);
LoadFromBlob(ADOQuery1.Fie ldByName(' bbnr'), FS);
FS.Free;
end;
function TForm1.LoadFromBlob(const AField: TField;
const Stream: TStream): boolean;
var
ResultStr: string;
PResultStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
ResultStr := AField.Value;
PResultStr := PChar(ResultStr);
Stream.Write(PResultStr^, Length(ResultStr));
Stream.Seek(0,0);
Result := true;
except
end;
end;
end;
function TForm1.SaveToBlob(const Stream: TStream;
const AField: TField): boolean;
var
FieldStr: string;
PFieldStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
Stream.Seek(0,0);
SetLength(FieldStr, Stream.Size);
PFieldStr := PChar(FieldStr);
Stream.Read(PFieldStr^, Stream.Size);
AField.Value := FieldStr;
Result := true;
except
end;
end;
end;
function TForm1.StoreFile: boolean;
var
MS: TFileStream;
begin
Result := false;
try
if OpenDialog1.Execute then
MS := TFileStream.Create(OpenDia log1.FileN ame,fmOpen Read);
Result := SaveToBlob(MS, ADODataSet1.FieldByName('b bnr'));
finally
MS.Free;
end;
end;
end.
wrong.
and Iwant to know how can I load the file content use Asp on internetexplorer.
thanks
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, Db, ADODB, StdCtrls,dbtables;
type
TForm1 = class(TForm)
Button1: TButton;
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
OpenDialog1: TOpenDialog;
Button2: TButton;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
function LoadFromBlob(const AField: TField; const Stream: TStream): boolean;
function SaveToBlob(const Stream: TStream; const AField: TField): boolean;
function StoreFile: boolean;
function LoadFile: boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
begin
try
ADOQuery1.Edit;
StoreFile;
ADOQuery1.Post;
except
ADOQuery1.Cancel;
end;
end;
procedure TForm1.Button2Click(Sender
begin
LoadFile;
end;
function TForm1.LoadFile: boolean;
var
FS: TFileStream;
begin
FS := TFileStream.Create(getcurr
LoadFromBlob(ADOQuery1.Fie
FS.Free;
end;
function TForm1.LoadFromBlob(const AField: TField;
const Stream: TStream): boolean;
var
ResultStr: string;
PResultStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
ResultStr := AField.Value;
PResultStr := PChar(ResultStr);
Stream.Write(PResultStr^, Length(ResultStr));
Stream.Seek(0,0);
Result := true;
except
end;
end;
end;
function TForm1.SaveToBlob(const Stream: TStream;
const AField: TField): boolean;
var
FieldStr: string;
PFieldStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
Stream.Seek(0,0);
SetLength(FieldStr, Stream.Size);
PFieldStr := PChar(FieldStr);
Stream.Read(PFieldStr^, Stream.Size);
AField.Value := FieldStr;
Result := true;
except
end;
end;
end;
function TForm1.StoreFile: boolean;
var
MS: TFileStream;
begin
Result := false;
try
if OpenDialog1.Execute then
MS := TFileStream.Create(OpenDia
Result := SaveToBlob(MS, ADODataSet1.FieldByName('b
finally
MS.Free;
end;
end;
end.
ASKER
Sorry,the follow is my source code,if I stored the text file ,it work well.but when I stored doc or xsl,it will be
wrong.
and Iwant to know how can I load the file content use Asp on internetexplorer.
thanks
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, Db, ADODB, StdCtrls,dbtables;
type
TForm1 = class(TForm)
Button1: TButton;
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
OpenDialog1: TOpenDialog;
Button2: TButton;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
function LoadFromBlob(const AField: TField; const Stream: TStream): boolean;
function SaveToBlob(const Stream: TStream; const AField: TField): boolean;
function StoreFile: boolean;
function LoadFile: boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender : TObject);
begin
try
ADOQuery1.Edit;
StoreFile;
ADOQuery1.Post;
except
ADOQuery1.Cancel;
end;
end;
procedure TForm1.Button2Click(Sender : TObject);
begin
LoadFile;
end;
function TForm1.LoadFile: boolean;
var
FS: TFileStream;
begin
FS := TFileStream.Create(getcurr entdir+'\T est2.doc', fmCreate);
LoadFromBlob(ADOQuery1.Fie ldByName(' bbnr'), FS);
FS.Free;
end;
function TForm1.LoadFromBlob(const AField: TField;
const Stream: TStream): boolean;
var
ResultStr: string;
PResultStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
ResultStr := AField.Value;
PResultStr := PChar(ResultStr);
Stream.Write(PResultStr^, Length(ResultStr));
Stream.Seek(0,0);
Result := true;
except
end;
end;
end;
function TForm1.SaveToBlob(const Stream: TStream;
const AField: TField): boolean;
var
FieldStr: string;
PFieldStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
Stream.Seek(0,0);
SetLength(FieldStr, Stream.Size);
PFieldStr := PChar(FieldStr);
Stream.Read(PFieldStr^, Stream.Size);
AField.Value := FieldStr;
Result := true;
except
end;
end;
end;
function TForm1.StoreFile: boolean;
var
MS: TFileStream;
begin
Result := false;
try
if OpenDialog1.Execute then
MS := TFileStream.Create(OpenDia log1.FileN ame,fmOpen Read);
Result := SaveToBlob(MS, ADODataSet1.FieldByName('b bnr'));
finally
MS.Free;
end;
end;
end.
wrong.
and Iwant to know how can I load the file content use Asp on internetexplorer.
thanks
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, Db, ADODB, StdCtrls,dbtables;
type
TForm1 = class(TForm)
Button1: TButton;
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
OpenDialog1: TOpenDialog;
Button2: TButton;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
function LoadFromBlob(const AField: TField; const Stream: TStream): boolean;
function SaveToBlob(const Stream: TStream; const AField: TField): boolean;
function StoreFile: boolean;
function LoadFile: boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
begin
try
ADOQuery1.Edit;
StoreFile;
ADOQuery1.Post;
except
ADOQuery1.Cancel;
end;
end;
procedure TForm1.Button2Click(Sender
begin
LoadFile;
end;
function TForm1.LoadFile: boolean;
var
FS: TFileStream;
begin
FS := TFileStream.Create(getcurr
LoadFromBlob(ADOQuery1.Fie
FS.Free;
end;
function TForm1.LoadFromBlob(const AField: TField;
const Stream: TStream): boolean;
var
ResultStr: string;
PResultStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
ResultStr := AField.Value;
PResultStr := PChar(ResultStr);
Stream.Write(PResultStr^, Length(ResultStr));
Stream.Seek(0,0);
Result := true;
except
end;
end;
end;
function TForm1.SaveToBlob(const Stream: TStream;
const AField: TField): boolean;
var
FieldStr: string;
PFieldStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
Stream.Seek(0,0);
SetLength(FieldStr, Stream.Size);
PFieldStr := PChar(FieldStr);
Stream.Read(PFieldStr^, Stream.Size);
AField.Value := FieldStr;
Result := true;
except
end;
end;
end;
function TForm1.StoreFile: boolean;
var
MS: TFileStream;
begin
Result := false;
try
if OpenDialog1.Execute then
MS := TFileStream.Create(OpenDia
Result := SaveToBlob(MS, ADODataSet1.FieldByName('b
finally
MS.Free;
end;
end;
end.
ASKER
I have stored a doc file into a mssql table with image type
,then I want to display on internetexplorer by asp .
how can I do
,then I want to display on internetexplorer by asp .
how can I do
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
To be PAQ/Refund
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thank you,
Russell
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
To be PAQ/Refund
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thank you,
Russell
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
save it to a file
call shellexecute