DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: webb123
今日帖子: 3
在线用户: 3
导航: 论坛 -> 数据库专区 斑竹:liumazi,waterstone  
作者:
男 dalas (dalas) ★☆☆☆☆ -
普通会员
2021/11/25 10:01:33
标题:
请教关于 ADO 打开 Excel 文件的两个问题 浏览:2454
加入我的收藏
楼主: 1、我已经安装了 Access database engine,如图1,为何在图2里仍找不到。

2、如何用代码获取图2的列表?
此帖子包含附件:
PNG 图像
大小:42.0K
----------------------------------------------
-
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2021/11/25 10:46:29
1楼: 按此在新窗口浏览图片
在一个sf引擎里面看到过
https://www.microsoft.com/zh-cn/download/details.aspx?id=13255
用的这个 改下语句就能用(x64 mdb)。其他未测。
demo不记得丢哪去了。  依稀记得就改了链接语句用代码不是在ui设置
刚发现这玩意分32 64 ...
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 dalas (dalas) ★☆☆☆☆ -
普通会员
2021/11/25 19:30:37
2楼: @ keymark (嬲)

感谢!!
第一个问题解决了,是64位的关系,IDE 不认64位的ACE。装32位,上图2列表里就出现了。

第二个问题还没解决,不知道怎么代码获取图2的列表。
此帖子包含附件:
PNG 图像
大小:19.9K
----------------------------------------------
-
作者:
男 pcplayer (pcplayer) ★☆☆☆☆ -
普通会员
2021/11/25 19:38:31
3楼: 楼主感觉你搞复杂了。

我记得 ADO 只要你双击 ConnectionString ,在弹出来的窗口里面做创建连接字符串的操作,选择系统里面安装了的 ADO 驱动,就可以了。
----------------------------------------------
-
作者:
男 pcplayer (pcplayer) ★☆☆☆☆ -
普通会员
2021/11/25 19:45:08
4楼: 搜了一下,有两篇文章讲的,都是用连接字符串的方式:

https://blog.csdn.net/songling418/article/details/14054359

https://blog.csdn.net/josencom/article/details/81953151
----------------------------------------------
-
作者:
男 dalas (dalas) ★☆☆☆☆ -
普通会员
2021/11/25 19:50:47
5楼: @pcplayer (pcplayer)

连接字符串已经实现了,我是想通过取 Provider 列表,判断当前系统是否安装了ACE,再程序里决定是否支持 .xlsx 文件的读写,否则就用 JET 只支持 .xls 格式。
----------------------------------------------
-
作者:
男 pcplayer (pcplayer) ★☆☆☆☆ -
普通会员
2021/11/25 19:52:39
6楼: 哦,那确实就要搞复杂了。
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2021/11/25 21:20:29
7楼: @dalas

you can try see on "REGISTY" key to verify if the "library" was founded or not... you see?

mabye on registry you can try see the info: directory installation, version, etc...

or

you can try load the "DLL" for each library and see if any error on load or not... later you can "unload it" ... you see?


another, maybe more easy:

1) on component TADOConnection you can see the list of possible "providers" founded in runtime

按此在新窗口浏览图片
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2021/11/25 22:03:03
8楼: 按此在新窗口浏览图片
在vista的时候我知道有一个文件后缀可以(双击出系统菜单)配置这个 具体不记得了 是在盒子还是哪里下
demos 看到的。
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2021/11/26 5:41:17
9楼: files:  *.DSN  ???
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2021/11/26 9:30:50
10楼: 配置ui 好像可以用代码调出来?可能记错了是别人写的?
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2021/11/26 10:20:53
11楼: @keymark
It seems that the configuration ui can be called out with code? Maybe someone else wrote it wrong?

---- ME:
I dont understood this translating?
What would be "configuration UI can be called out with code?"
some (simple code) example to my understanding???
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2021/11/26 10:50:02
12楼: unit Unit1;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  FireDAC.Phys.ODBCDef,
  FireDAC.UI.Intf,
  FireDAC.VCLUI.Wait,
  FireDAC.Stan.Intf,
  FireDAC.Stan.Option,
  FireDAC.Stan.Error,
  FireDAC.Phys.Intf,
  FireDAC.Stan.Def,
  FireDAC.Stan.Pool,
  FireDAC.Stan.Async,
  FireDAC.Phys,
  Vcl.StdCtrls,
  Data.DB,
  FireDAC.Comp.Client,
  FireDAC.Comp.UI,
  FireDAC.Phys.ODBCBase,
  FireDAC.Phys.ODBC;

type
  TForm1 = class(TForm)
    FDPhysODBCDriverLink1: TFDPhysODBCDriverLink;
    FDGUIxWaitCursor1: TFDGUIxWaitCursor;
    FDConnection1: TFDConnection;
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  MyListDriversODBC_inMyWindows: TStringList;
begin
  MyListDriversODBC_inMyWindows := TStringList.Create;
  try
    //
    FDPhysODBCDriverLink1.GetDrivers(MyListDriversODBC_inMyWindows);
    //
    ListBox1.Items.AddStrings(MyListDriversODBC_inMyWindows);
  finally
    MyListDriversODBC_inMyWindows.Free;
  end;
end;

end.

按此在新窗口浏览图片
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2021/11/26 11:06:53
13楼: procedure TForm1.Button2Click(Sender: TObject);
var
  MyIndex   : integer;
  MyLocale  : integer;
  MyTypeInfo: TTypeInfo;
  MyKindName: string;
begin
  ADOConnection1.ConnectionString := '.......';
  ADOConnection1.Connected        := true;
  //
  // MyIndex  := ?;
  // MyLocale := ?;
  ADOConnection1.Properties.GetTypeInfo(MyIndex, MyLocale, MyTypeInfo);
  //
  ShowMessage(          { }
    string(MyTypeInfo.Name) +          { }
    GetEnumName(TypeInfo(TTypeKind), ord(MyTypeInfo.Kind)) + { }
    MyTypeInfo.NameFld.ToString          { }
    );
  //
  // MyTypeInfo.TypeData.xxxx
end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 littlestone08 (littlestone08) ★☆☆☆☆ -
普通会员
2021/11/26 15:50:08
14楼: ADOConEd.pas

function EditConnectionString(Component: TComponent): Boolean;

也许8楼说的是这个,就算不是楼主所要的,也可以提供足够的参考了
----------------------------------------------
我和我追逐的梦,擦肩而过
作者:
男 dalas (dalas) ★☆☆☆☆ -
普通会员
2021/11/26 16:14:43
15楼: uses
  Winapi.ActiveX,  Data.Win.ADODB, Data.DB, oledb, System.Win.ComObj;


procedure TfrmMain.Button1Click(Sender: TObject);

function PromptDataSource(ParentHandle: THandle; InitialString: WideString): WideString;
var
  DataInit: IDataInitialize;
  DBPrompt: IDBPromptInitialize;
  DataSource: IUnknown;
  InitStr: PWideChar;
begin
  Result := InitialString;
  DataInit := CreateComObject(CLSID_DataLinks) as IDataInitialize;
  if InitialString <> '' then
    DataInit.GetDataSource(nil, CLSCTX_INPROC_SERVER,
      PWideChar(InitialString), IUnknown, DataSource);
  DBPrompt := CreateComObject(CLSID_DataLinks) as IDBPromptInitialize;
  if Succeeded(DBPrompt.PromptDataSource(nil, ParentHandle,
    DBPROMPTOPTIONS_PROPERTYSHEET, 0, nil, nil, IUnknown, DataSource)) then
  begin
    InitStr := nil;
    DataInit.GetInitializationString(DataSource, True, InitStr);
    Result := InitStr;
  end;
end;
begin
  PromptDataSource(Handle, memo1.Text)
end;

执行结果如下图,这个列表里能取到也行啊,怎么搞出来呢?
此帖子包含附件:
PNG 图像
大小:21.2K
----------------------------------------------
-
作者:
男 pcplayer (pcplayer) ★☆☆☆☆ -
普通会员
2021/11/26 17:46:25
16楼: 15楼,你的意思是不是你想用程序获得你那个图里面的内容?

7 楼说了,查注册表。其实这些内容都在注册表里面。
----------------------------------------------
-
作者:
男 dalas (dalas) ★☆☆☆☆ -
普通会员
2021/11/26 18:45:10
17楼: 注册表里的不知道怎么判断32位还是64位的,如果是64位的,程序是32位,也是用不了的
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2021/11/26 22:14:25
18楼: @dalas maybe help you

uses
  System.Win.Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
  MyRegistry    : TRegistry;
  WhatIShouldUse: integer;
begin
{$IFDEF WIN32}
  WhatIShouldUse := KEY_WOW64_32KEY;
{$ELSE} // if not have others platforms...
  WhatIShouldUse := KEY_WOW64_64KEY;
{$ENDIF}
  //
  MyRegistry := TRegistry.Create(KEY_ALL_ACCESS or WhatIShouldUse); // Help: System.Win.Registry.TRegistry.Access ... <-- other mode
  try
    //
    MyRegistry.RootKey := HKEY_CURRENT_USER;
    //
    Label1.Caption := MyRegistry.RootKeyName;
    //
    if MyRegistry.OpenKey('Software' { \WOW6432Node' } , false) then // HKEY_LOCAL_MACHINE
    begin
      //
      if MyRegistry.KeyExists('WOW6432Node') then
      begin
        if MyRegistry.OpenKey('WOW6432Node', false) then
          MyRegistry.GetKeyNames(ListBox1.Items)
        else
          ShowMessage('It was not possible open it - 2');
      end;
      //
      ShowMessage('This is the key content...')
    end
    else
      ShowMessage('It was not possible open it - 1 ');
  finally
    if not(MyRegistry = nil) then
    begin
      MyRegistry.CloseKey;
      MyRegistry.Free;
    end;
  end;
end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 dalas (dalas) ★☆☆☆☆ -
普通会员
2021/11/27 11:48:42
19楼: @emailx45 (emailx45)

我没有说楚,windows 是64位,我的程序是32位,只能使用 32位的ACE,如果安装的ACE是64位,也是用不了的。我在注册表里搜索 Microsoft.ACE.OLEDB.12.0,可以搜出一大堆,其中有些严重怀疑是上次安装的64位ACE的卸载残留物。无法判断哪个是32位ACE的注册信息。
我在另一台电脑安装了64位的ACE,两台电脑注册表搜索 Microsoft.ACE.OLEDB.12.0 对比,发现居然都完全一样的。
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2021/11/27 16:08:11
20楼: on registry you go found the keys to DLLs, be 32 or 64bits installed, BECAUSE IT'S NOT POSSIBLE INSTALL TWO VERSION IN SAME MSWINDOWS.
-- or you install 32bits, or install 64bits -- not two taste!!!

in my sample, above, I did:

1) I installed ACE 32bits by Microsoft download
2) in RAD 11, I did a 32bits project with code above
3) build and run... the screenshot above show the resulted

later...

1) uninstalled 32bits, and installed 64bits of ACE 
2) using same project I just added new platform 64bits
3) build and run and you can see the screenshot above.

summary: same in MSWindows 10 64bits, you can just install "1" of "2" taste of ACE, or be:  install 32bits or install 64bits.

in Delphi, you can have same project and compiling in 32bits or 64bits and all works.

Then, you can see that "in MSWindows" you'll have just one DLL taste, not two.

you see me?
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 dalas (dalas) ★☆☆☆☆ -
普通会员
2022/2/22 19:48:01
21楼: 完美解决!!
今天想起来这个贴子,把解决方法贴上来,或许有人也有用呢

function GetProviderVer():String;
const
  ACE='Microsoft.ACE.OLEDB.';
var
  Names: TStrings;
  iIndex:Integer;
begin
  Result:='';
  Names:=TStringList.Create;
  try
    GetProviderNames(Names);
    for iIndex := 0 to Names.Count-1 do
    begin
      if Pos(ACE,Names[iIndex])>0 then
      begin //Microsoft.ACE.OLEDB.12.0
        Result:=Names[iIndex];
        //Result:=Result.Substring(ACE.Length,Result.Length-ACE.Length);
        Break;
      end;
    end;
  finally
    Names.Free;
  end;
end;
此帖子包含附件:
PNG 图像
大小:39.5K
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行164.0625毫秒 RSS