Solved

how can i save a excel file to sqlserver and display it on web

Posted on 2001-08-08
11
170 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:gutian
11 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6363056
read out the content,
save it to a file
call shellexecute
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6363061
to be more specific,
i need to know the database and
the connection-type(bde,odbc,ado,other)
0
 

Author Comment

by:gutian
ID: 6363256
I used Ado
I have used TAdoblobstream,it work not well
0
 

Author Comment

by:gutian
ID: 6363291
and I want to auto finish the work ,user look the file use
internetexplorer
0
 

Author Comment

by:gutian
ID: 6363746
kretzschmar :
        Can you tell me all ways.Thank you very mach
!!!!!!!!!!!!!!!!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:lbseong
ID: 6364532
just give more information ok?
if u want to show,I think u can use the assignfile do view the file,right?
0
 

Author Comment

by:gutian
ID: 6366671
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(getcurrentdir+'\Test2.doc', fmCreate);
    LoadFromBlob(ADOQuery1.FieldByName('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(OpenDialog1.FileName,fmOpenRead);
      Result := SaveToBlob(MS, ADODataSet1.FieldByName('bbnr'));
    finally
      MS.Free;
    end;
  end;

end.
0
 

Author Comment

by:gutian
ID: 6367212
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(getcurrentdir+'\Test2.doc', fmCreate);
    LoadFromBlob(ADOQuery1.FieldByName('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(OpenDialog1.FileName,fmOpenRead);
      Result := SaveToBlob(MS, ADODataSet1.FieldByName('bbnr'));
    finally
      MS.Free;
    end;
  end;

end.
0
 

Author Comment

by:gutian
ID: 6424479
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
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8741497
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
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 8822553
Per recommendation,

PashaMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now