delphi如何向SQL SERVER 中存取word文档

先说一下我程序的进展吧。我建立了数据库test1,其中表名t1,有4列,序号xh、拟稿人ngr、存储路径lj、内容nr,其中我想把WORD文档存储到nr列中,nr列我设置... 先说一下我程序的进展吧。
我建立了数据库test1,其中表名t1,有4列,序号xh、拟稿人ngr、存储路径lj、内容nr,其中我想把WORD文档存储到nr列中,nr列我设置成了image了。
我现在可以用三个dbedit输入前三列,用opendialog打开word文档,用olecontainer显示word文档的内容。我想知道,如何把这四列的内容存进数据库,主要是word文档。请尽量用我的列名,说的详细些,谢谢。
展开
 我来答
chunlizh
2010-10-20 · 超过27用户采纳过TA的回答
知道答主
回答量:157
采纳率:0%
帮助的人:78.9万
展开全部
Unit1.dfm

object Form1: TForm1
Left = 192
Top = 133
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 8
Top = 24
Width = 561
Height = 393
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object Button1: TButton
Left = 584
Top = 32
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
end
object Button2: TButton
Left = 584
Top = 72
Width = 75
Height = 25
Caption = 'Button2'
TabOrder = 2
OnClick = Button2Click
end
object Button3: TButton
Left = 584
Top = 112
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 3
end
object Button4: TButton
Left = 584
Top = 152
Width = 75
Height = 25
Caption = 'Open Word'
TabOrder = 4
OnClick = Button4Click
end
object mySQLDatabase1: TmySQLDatabase
Connected = True
DatabaseName = 'test'
UserName = 'root'
UserPassword = 'tearsofthesun'
Host = '127.0.0.1'
ConnectOptions = []
Params.Strings = (
'Port=3306'
'TIMEOUT=30'
'DatabaseName=test'
'Host=127.0.0.1'
'UID=root'
'PWD=tearsofthesun')
Left = 16
Top = 72
end
object mySQLQ_sel: TmySQLQuery
Database = mySQLDatabase1
SQL.Strings = (
'select word from test where a=:id')
Left = 176
Top = 120
ParamData = <
item
DataType = ftUnknown
Name = 'id'
ParamType = ptUnknown
end>
object mySQLQ_selword: TBlobField
FieldName = 'word'
Size = 4
end
end
object DataSource1: TDataSource
DataSet = mySQLTable1
Left = 56
Top = 120
end
object WordDocument1: TWordDocument
AutoConnect = False
ConnectKind = ckRunningOrNew
OnClose = WordDocument1Close
Left = 624
Top = 208
end
object WordApplication1: TWordApplication
AutoConnect = False
ConnectKind = ckRunningOrNew
AutoQuit = False
OnDocumentBeforeClose = WordApplication1DocumentBeforeClose
OnDocumentBeforeSave = WordApplication1DocumentBeforeSave
Left = 584
Top = 208
end
object mySQLQ_update: TmySQLQuery
Database = mySQLDatabase1
SQL.Strings = (
'update test set word=:w where a=:id')
Left = 240
Top = 120
ParamData = <
item
DataType = ftBlob
Name = 'w'
ParamType = ptInput
end
item
DataType = ftUnknown
Name = 'id'
ParamType = ptUnknown
end>
end
object mySQLTable1: TmySQLTable
Database = mySQLDatabase1
Active = True
TableName = 'test'
Left = 16
Top = 120
object mySQLTable1a: TAutoIncField
FieldName = 'a'
end
object mySQLTable1b: TStringField
FieldName = 'b'
end
end
object Timer1: TTimer
Enabled = False
OnTimer = Timer1Timer
Left = 592
Top = 256
end
end

//关键代码,仅3行
//保存压缩后的doc文件到数据库
mySQLQ_update.Params[0].LoadFromFile(zipDocF,ftBlob);
mySQLQ_update.Params[1].AsInteger := curID;
mySQLQ_update.ExecSQL;
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式