难,难,难!使用OLE对象将autocad图纸存入SQLSERVER数据库中(200分)

  • 主题发起人 主题发起人 龙力
  • 开始时间 开始时间

龙力

Unregistered / Unconfirmed
GUEST, unregistred user!
请教各位高手,我想通过OLE对象插入AUTOCAD图纸,并进行编辑,然后将图纸存入数据库中,不知有什么办法???急切等待各位的帮助
 
先存成文件,再从文件装入数据库
 
OleContainer1.SaveAsDocument(FileName);
 
以前作过对Word的操作 估计Cad也差不多
感觉ole很差劲 也许我用的不熟 给点小思路:
把文件写入 Blob 字段:
procedure TForm1.btnSaveClick(Sender: TObject);
var
FStream: TFileStream;
BStream: TBlobStream;
begin
if not OpenDialog1.Execute then exit;
FStream := TFileStream.Create(OpenDialog1.FileName,fmOpenRead);
Table1.Edit;
BStream := TBlobStream.Create(Table1Doc,bmReadwrite);
BStream.CopyFrom(FStream,FStream.Size);
Table1.Post;
BStream.Free;
FStream.Free;
btnReadDoc.Enabled := false;
btnReadPic.Enabled := false;
end;
 
还有一段转载的程序如下:
procedure TMainForm.NewMenuClick(Sender: TObject);
begin
MainPage.ActivePage := EditSheet;

MyWord:= CoApplication_.Create;
FileName := 'C:/My Documents/HHH.doc';
MyWord.Documents.Open(FileName,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam);

OleContainer1.DoVerb( ovShow );
end;

procedure TMainForm.CloseMenuClick(Sender: TObject);
var
OleStream : TMemoryStream;
begin
OleStream := TMemoryStream.Create;
Myword._Release;
OleContainer1.SaveToStream( OleStream );
OleStream.Position := 0;
with dm1.InsertTable do
begin
Close;
Open;
Edit;
//Append;
FieldByName( 'title' ).asstring := 'ok,letgo';
TBlobField( fieldbyname('ole') ).LoadFromStream( OleStream );
post;
begin
dm1.db2.StartTransaction;
try
ApplyUpdates; {try to write the updates to the database};
dm1.Db2.Commit; {on success, commit the changes};
except
dm1.Db2.Rollback; {on failure, undo the changes};
raise; {raise the exception to prevent a call to CommitUpdates!}
end;
CommitUpdates; {on success, clear the cache}
end;
//ApplyUpdates;
showmessage( 'done' );
end;
OleStream.Free;
end;
 
原来做过存储xxx.cll文件,作为2进制文件读取进来,直接存入数据库的varchar字段

varchar长度好像是8000
 
to:仙剑奇侠
怎么样将存的文件赋给数据库呢(以什么格式)???
 
TBlobField(adoquery1.FieldByName('fieldname')).LoadFormFile(FileName);
祝你好运!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部