|
代码如下:
query := TQuery.Create(nil);
query.ConnectionString := 'DATABASEURL=Biz:\SCMISYWKJ\SCMISSJK.Database';
query.CommandText := 'insert into ' +
' DD_JJBJLB(GUID, RQ, RY, JBRY, BZ, JBBZ, ZC, JBZC, RZLB, RZNR, DBBC, BZGUID) ' +
'values (:GUID, :RQ, :RY, :JBRY, :BZ, :JBBZ, :ZC, :JBZC, :RZLB, :RZNR, BBC, :BZGUID)';
query.Params.ParamByName('GUID').AsString := Business.System.JSCommon.CreateGUIDStr;
query.Params.ParamByName('RQ').AsDateTime := SysUtils.StrToDateTime(DTPicker_login.Text);
query.Params.ParamByName('RY').AsString := self.getDQBNR('zbryxm');
query.Params.ParamByName('JBRY').AsString := JBRXM;
query.Params.ParamByName('ZC').AsString := getDQBNR('bcid');
query.Params.ParamByName('JBZC').AsString := getJBNR('bcid');
query.Params.ParamByName('RZLB').AsString := DDLB;
//TBlobField(query.Params.ParamByName('RZNR')).LoadFromStream(sm);
query.Params.ParamByName('RZNR').LoadFromStream(sm, TFieldType.ftBlob);
lContextCurrent := Business.Model.TContextCurrent.Create(Self.Context);
query.Params.ParamByName('BZGUID').AsString := lContextCurrent.Dept.ID;
if not DataSetBroker_bcb.DataSet.Active then
DataSetBroker_bcb.DataSet.Open;
DataSetBroker_bcb.DataSet.Filter:='BCGUID='''+getDQBNR('bcid')+'''';
DataSetBroker_bcb.DataSet.Filtered:=true;
if DataSetBroker_bcb.DataSet.RecordCount=1 then
query.Params.ParamByName('DBBC').AsString := DataSetBroker_bcb.DataSet.FieldByName('BCMC').Text; //交班班次
query.Params.ParamByName('BZ').AsString := '('+ZYJ_XTCZHS.TZYJ_XTCZHS.GetCurrentUserName(self.Context)+')交班成功,值班人员('+self.getDQBNR('zbryxm')+')';
query.Params.ParamByName('JBBZ').AsString := '('+ qmry.Caption+')接班成功,当前值班人员('+JBRXM+')'; //2009-4-15
query.Execute;
关键在后面这两句:
//TBlobField(query.Params.ParamByName('RZNR')).LoadFromStream(sm);
query.Params.ParamByName('RZNR').LoadFromStream(sm, TFieldType.ftBlob);
如果我用第一种注释的方法,X3会报错;如果我用第二种方法,在打开EXCEL时候会报 Out of Memory
想问下各位,如果我想用TQuery来保存EXCEL或者WORD文件的话,应该如何写代码捏? |
|