随着delphi 10.2 开始了对Linux 的重新支持。devart 也迅速的发布了unidac 7.0,

最大的特性就是支持linux和MongoDB.

并有了其他更新:

In this release we added such significant features as:

  • The new UniDAC version includes a new MongoDB provider which allows you to work with a cross-platform document-oriented database MongoDB. Its main features are high performance, easy deployment and comprehensive support for the latest versions of the MongoDB server.
  • In DBF provider, we added support for the Direct mode. Using DBF data provider, you can work with a variety of database formats: dBaseIII-dBase10, dBase for Windows, HiPer-Six, FoxPro 2, Visual FoxPro.
  • Now, working with Oracle in the Direct mode becomes more appealing, we supported Oracle 12c authentication, Oracle Cloud (DbaaS), Oracle Encryption, Oracle Data Integrity. We also added support for the ANYDATA type.
  • What is more, for Interbase and Firebird, you have an opportunity to manage batch operations using a transaction and to obtain an active transaction number using DBMonitor.
  • In NexusDB data provider, we added support for using ConnectionString and the TFmtBCD fields.

更多的情况可以访问官网www.devart.com  .此公司在数据库存取方面的功力,已经逆天。

今天给大家说的是利用undiac 的直连数据库功能,在Linux下不安装任何驱动,访问MS SQLSERVER 功能。

如果你没有现成的sql server 数据库,可以直接在微软的网页上下载sql server 2016 express 版,此版本为免费版本。

安装后,启动TCP/IP 支持,同时注意windows 防火墙的设置,确保网络访问正常。

在windows 上,使用客户端程序,建立一个sql server 数据库,同时建一个测试表。

输入一些测试数据

OK, 准备结束。启动delphi。

新建一个控制台工程。

再建一个datamodule

放上对应的控件

注意uniconnection 的属性设置

 

 ok, 设置完毕

回到主程序。

program linuxdata;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,System.Classes,
  dmp in 'dmp.pas' {dmf: TDataModule};

var
  i:integer;
  s:string;
begin

  try
   dmf:=Tdmf.Create(nil);
   dmf.UniConnection1.Connected:=true;
   writeln('数据库版本:'+dmf.UniConnection1.ServerVersionFull);
with dmf.cx do begin SQL.Clear; sql.Add('select * from TB_user'); open; for I := 0 to fields.Count-1 do begin write('|'); write( fields[i].FieldName); end; writeln('|'); while not eof do begin for I := 0 to fields.Count-1 do begin write('|'); write( fields[i].AsString) ; end; writeln('|'); next; end; end; writeln('打完收功!'); readln; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.

在windows 上运行无误。

 

添加linux 平台编译支持

编译,运行程序

 

 

 结果出来了。与windows 下没任何区别。

记住:我们没有在linux 下安装任何sql server 驱动。

用delphi 就这么自信!

另外,以上人名,纯属虚构,如有雷同,爱理不理。

 

posted on 2017-04-09 12:09  xalion  阅读(2190)  评论(5编辑  收藏  举报