码迷,mamicode.com
首页 > 数据库 > 详细

TDatabase TQuery TDataSource TDBGrid 设定方法

时间:2016-08-06 16:00:20      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:

TDatabase TQuery TDataSource TDBGrid
object Database1: TDatabase
  AliasName = sfis
  DatabaseName = Allcon
  LoginPrompt = False
  Params.Strings = (
    SERVER NAME=SFIS.WORLD
    USER NAME=sfis1
    NET PROTOCOL=TNS
    OPEN MODE=READ/WRITE
    SCHEMA CACHE SIZE=8
    LANGDRIVER=taiwan
    SQLQRYMODE=SERVER
    SQLPASSTHRU MODE=SHARED AUTOCOMMIT
    SCHEMA CACHE TIME=-1
    MAX ROWS=-1
    BATCH COUNT=200
    ENABLE SCHEMA CACHE=FALSE
    SCHEMA CACHE DIR=
    ENABLE BCD=FALSE
    ENABLE INTEGERS=FALSE
    LIST SYNONYMS=NONE
    ROWSET SIZE=20
    BLOBS TO CACHE=64
    BLOB SIZE=32
    OBJECT MODE=TRUE
    PASSWORD=sfcbasetable1)
  ReadOnly = True
  SessionName = Default
end
object Query1: TQuery
  DatabaseName = Allcon
end
object DataSource1: TDataSource
  DataSet = Query1
end
object DBGrid1: TDBGrid
  DataSource = DataSource1
end
//没有参数查询
Query1.Close; Query1.SQL.Clear; Query1.SQL.Add(
SELECT * FROM SFISM4.R_MATERIAL_EXC_T); Query1.Open;
//传参时

sn:=‘MATERIAL_SN=:sn‘;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(‘SELECT * FROM SFISM4.R_MATERIAL_EXC_T where ‘+sn);
Query1.ParamByName(‘sn‘).AsString := Edit_Qry_KPNO.Text;
Query1.Open;

//插入 或更新操作时
 query1.Close;
      query1.SQL.Clear;
query1.SQL.Add(INSERT INTO SFISM4.R_MATERIAL_EXC_T (MATERIAL_SN,VENDER,DATA_CODE,LOC_CODE,EXC_TIME,EXC_CODE,ERROR_REASON,BAR_RATE,REASON_COME,CLEAR_FLAG,CLEAR_CODE,CLOSE_FLAG,CLEAR_TIME,QUA_DC,EIGHT_D_CODE,EIGHT_D_ADD,VC_CONTACT,SQE_CONTACT)  +
                       VALUES ( :MATERIAL_SN,:VENDER,:DATA_CODE,:LOC_CODE,:EXC_TIME,:EXC_CODE,:ERROR_REASON,:BAR_RATE,:REASON_COME,:CLEAR_FLAG,:CLEAR_CODE,:CLOSE_FLAG,:CLEAR_TIME,:QUA_DC,:EIGHT_D_CODE,:EIGHT_D_ADD,:VC_CONTACT,:SQE_CONTACT));
        query1.ParamByName(MATERIAL_SN).AsString:=Edit_KP.Text;
       //...此处省去其他参数赋值
        query1.ExecSQL;

query1.SQL.Add(‘UPDATE SFISM4.R_MATERIAL_EXC_T SET MATERIAL_SN=:MATERIAL_SN,VC_CONTACT=:VC_CONTACT,SQE_CONTACT=:SQE_CONTACT‘+‘ ‘+
‘where MATERIAL_SN=:MATERIAL_SN ‘)

 

 

      date11:= formatdatetime(YYYYMMDD,DT_ex_Begin.date);        //?date??Θ?‘‘/‘‘才﹃
      date22:= formatdatetime(YYYYMMDD,DT_ex_End.date);
      time11:= Time1.text; //格式为 13:30 
      time22:= time2.text;
      ssql:=SELECT * FROM SFISM4.R_MATERIAL_EXC_T where EXC_TIME  between to_date(‘‘+Date11+‘‘ || ‘‘+ time11+‘‘,‘‘YYYYMMDDhh24:miss‘‘) and to_date(‘‘+Date22+‘‘ || ‘‘+ time22+‘‘,‘‘YYYYMMDDhh24:miss‘‘) ;

 

TDatabase TQuery TDataSource TDBGrid 设定方法

标签:

原文地址:http://www.cnblogs.com/rogge7/p/5744179.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!