RSS订阅 | 匿名投稿
您的位置:网站首页 > 数据库 > 正文

Delphi里动态创建Access的交叉表视图

作者:admin 来源: 日期:2016/1/20 10:40:46 人气: 标签:

const
  dbUseJet = $00000002;
var
  connection: OleVariant;
  DBEngine : OleVariant;
  DataBase : OleVariant;
  QueryDef : OleVariant;
  accessfile: string;
  sql: string;
begin
  accessfile := 'C:/db1.mdb';

  connection := CreateOleObject('Access.Application');
  DBEngine := connection.DBEngine;
  DBEngine.DefaultType := DBUseJet;
  DataBase := DBEngine.OpenDatabase(accessfile);
  sql := ' TRANSFORM first(FieldValue) '
      + ' SELECT ContactID FROM [SELECT a.FieldName, b.ContactID, b.FieldID, '
      + ' b.FieldValue FROM CustomField AS a, ContactFieldValue AS b WHERE '
      + ' a.RecordID = b.FieldID]. AS TmpTable GROUP BY ContactID PIVOT FieldName';
  QueryDef := Database.CreateQueryDef('V_CustomValue',sql);    
  connection.Close();
end;

读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址:
下一篇:没有资料