萬能查詢器DLL使用說明 http://www.absky.cn/?product-80.html

銷售網址:http://www.absky.cn/?product-80.html

 

1、萬能查詢器DLL帶自動分頁功能, 它的自動分頁功能,避開存儲過程分頁和數據集分頁,直接自動在取數之前就分好。相比其它形式的分頁更簡單實用且運行速度更快。


2、可以以OleVariant形式返回指定的單個值,單行數據,多行數據,返回查詢語句,還可以手動修改自動生成的查詢語句,做到真正的方便實用。

 

4、全部功能集中在一個DLL文件中,調用相關的函數即可,方便實用。

 

3、支持smallint,int,string,datetime,date等數據類型的字段的模糊查詢。更貼進用戶的使用習慣。

 

 

 

運行效果圖1

 

 

運行效果圖2

 

運行效果圖3

 

 

 

運行效果圖4

 

 

運行效果圖5

 

 

實例代碼說明:

ConnectionString:= Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=127.0.0.1

 

CommandText :=select OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry from Orders

 

DLL引出函數說明:

 

 

1Function GetDialogFieldValue(ParentHandle:THandle;ConnectSql,SqlText,ReturnFieldName:WideString;Out Value:OleVariant):Boolean;stdcall;

 

作用: 根據傳入參數,返回指定字段的選定值; 執行成功返回True,否則返回False;

參數說明:

    ParentHandle    THandle      ----- 調用此函數的程序句柄; 

    ConnectSql      WideString    ----- 數據庫連接字符串;

    SqlText         WideString    ----- 查詢的SQL語句;

    ReturnFieldName WideString    ----- 返回值的字段名,缺省爲第一個字段的值;

    Value:            OleVariant     ----- 返回值;

 

調用實例代碼:

var

   GetDialogFieldValue:Function(PHandle:THandle;ConnectSql,SqlText,ReturnFieldName:WideString;Out Value:OleVariant):Boolean;stdcall;

   value:OleVariant;

   LibHandle: THandle;

begin

  try

    LibHandle := LoadLibrary(pChar('E:/ProfitSky/Dll/QueryDialog/QueryDialog.dll'));

    @GetDialogFieldValue := GetProcAddress(LibHandle,'GetDialogFieldValue');

    if Assigned(GetDialogFieldValue) then

    begin

      if GetDialogFieldValue(Handle,ConnectionString,CommandText,'',value) then

      ShowMessage(VarToStr(value));

    end;

  finally

    FreeLibrary(LibHandle);

  end;

end;

 

2Function GetDialogSingleRowValue( ParentHandle:THandle;ConnectSql,SqlText:WideString;

ColumnWidthArray:OleVariant;Out Value:OleVariant):Boolean;stdcall;

 

作用:根據傳入參數,生成查詢數據集,返回選擇行的整行值;執行成功返回True,否則返回False;

參數說明:

    ParentHandle      THandle      ----- 調用此函數的程序句柄; 

    ConnectSql        WideString    ----- 數據庫連接字符串;

    SqlText           WideString    ----- 查詢的SQL語句;

    ColumnWidthArray OleVariant     ----- 標識每列寬度,原型爲Array of Integer

    Value:              OleVariant     ----- 返回值;原型爲Array of OleVariant;

 

調用實例代碼:

 

var

   j:Integer;

   ivalue:OleVariant;

    s:Array of OleVariant;

   GetDialogSingleRowValue:Function(ParentHandle:THandle;ConnectSql,SqlText:WideString;ColumnWidthArray:OleVariant;Out Value:OleVariant):Boolean;stdcall;

begin

  try

    LibHandle := LoadLibrary(pChar('E:/ProfitSky/Dll/QueryDialog/QueryDialog.dll'));

    @GetDialogSingleRowValue := GetProcAddress(LibHandle,'GetDialogSingleRowValue');

    if Assigned(GetDialogSingleRowValue) then

    begin

      if GetDialogSingleRowValue(Handle,ConnectionString,'select OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShipCountry from Orders',

       VarArrayOf([0,0,80,80,80,80]),ivalue) then

       begin

          s:=ivalue;

          for j:=0 to length(s)-1 do

            ShowMessage(VarToStr(s[j]));

       end;

    end;

  finally

    FreeLibrary(LibHandle);

    ivalue:=null;

        s:=nil;

  end;

end;

 

 

3Function GetDialogMultiRowValue(ParentHandle:THandle;ConnectSql,SqlText:WideString;

ColumnWidthArray:OleVariant;Out Value:OleVariant):Boolean;stdcall;

 

作用:根據傳入參數,生成查詢數據集,返回選擇的多行的值;執行成功返回True,否則返回False;

參數說明:

    ParentHandle      THandle      ----- 調用此函數的程序句柄; 

    ConnectSql        WideString    ----- 數據庫連接字符串;

    SqlText           WideString    ----- 查詢的SQL語句;

    ColumnWidthArray OleVariant     ----- 標識每列寬度,原型爲Array of Integer

    Value:              OleVariant     ----- 返回值;原型爲Array of Array of OleVariant;;

 

調用實例代碼:

 

var

   i,j:Integer;

   ivalue:OleVariant;

   s:Array of Array of OleVariant;   GetDialogMultiRowValue:Function(ParentHandle:THandle;ConnectSql,SqlText:WideString;ColumnWidthArray:

OleVariant;Out Value:OleVariant):Boolean;stdcall;

begin

  try

    LibHandle := LoadLibrary(pChar('E:/ProfitSky/Dll/QueryDialog/QueryDialog.dll'));

    @GetDialogMultiRowValue := GetProcAddress(LibHandle,'GetDialogMultiRowValue');

    if Assigned(GetDialogMultiRowValue) then

    begin

      if GetDialogMultiRowValue(Handle,ConnectionString,'select OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShipCountry from Orders',

       VarArrayOf([0,0,80,80,80,80]),ivalue) then

       begin

          s:=ivalue;

          for i:=0 to HIGH(s) do

          for j:=0 to length(s[i])-1 do

            ShowMessage(VarToStr(s[i][j]));

       end;

    end;

  finally

    FreeLibrary(LibHandle);

    ivalue:=null;

    s:=nil;

  end;

end;

 

 

4Function GetDialogSqlWhereExpression(ParentHandle:THandle;ConnectSql:WideString;

DynamicArray:OleVariant;out Value:WideString):Boolean;stdcall;

 

作用:根據傳入參數,生成查詢項目,返回查詢字符串;執行成功返回True,否則返回False;

參數說明:

    ParentHandle      THandle      ----- 調用此函數的程序句柄; 

    ConnectSql        WideString    ----- 數據庫連接字符串;

    DynamicArray     OleVariant     ----- 標識項目內容的數組,原型爲Array of Variant

                                         格式爲 [字段名, 字段顯示名,數據類型, 查詢列表的SQL語句]

    Value:              WideString    ----- 返回值;格式爲 Where sql expression Order by sql expression;

 

調用實例代碼:

var

   ivalue:WideString;

   GetDialogSqlWhereExpression:Function(ParentHandle:THandle;ConnectSql:WideString;DynamicArray:OleVariant;out Value:WideString):Boolean;stdcall;

begin

  try

    LibHandle := LoadLibrary(pChar('E:/ProfitSky/Dll/QueryDialog/QueryDialog.dll'));

    @GetDialogSqlWhereExpression := GetProcAddress(LibHandle,'GetDialogSqlWhereExpression');

    if Assigned(GetDialogSqlWhereExpression) then

    begin

      if GetDialogSqlWhereExpression(Handle,ConnectionString,

      VarArrayOf(['OrderID','訂單ID',varString,'select OrderID AS 訂單ID from Orders',

                  'CustomerID','客戶ID',varString,'select CustomerID AS 客戶ID from Orders',

                  'EmployeeID','員工ID',varString,'select EmployeeID AS 員工ID from Orders',

                  'OrderDate','訂單日期',varDate,'select OrderDate AS 訂單日期1, OrderDate AS 訂單日期2, OrderDate AS 訂單日期3 from Orders',

                  'RequiredDate','需求日期',varDate,'select RequiredDate AS 需求日期 from Orders',

                  'ShipCountry','船運國',varString,'select ShipCountry AS 船運國 from Orders']),ivalue) then

       begin

            ShowMessage(ivalue);

       end;

    end;

  finally

    FreeLibrary(LibHandle);

  end;

end;

 

 

5Function GetExecuteSingleRowValue(ParentHandle:THandle;ConnectSql,SqlText:WideString;

out Value:OleVariant):Boolean;stdcall;

 

作用:根據傳入參數,執行SQL語句後返回查詢的單行值;執行成功返回True,否則返回False;

參數說明:

    ParentHandle      THandle      ----- 調用此函數的程序句柄; 

    ConnectSql        WideString    ----- 數據庫連接字符串;

    SqlText           WideString    ----- 查詢的SQL語句;

   Value           OleVariant     ----- 返回值;原型爲Array of OleVariant;

 

調用實例代碼:

 

var

   j:Integer;

   ivalue:OleVariant;

    s:Array of OleVariant;

   GetExecuteSingleRowValue:Function(ParentHandle:THandle;ConnectSql,SqlText:WideString;out Value:OleVariant):Boolean;stdcall;

begin

  try

    LibHandle := LoadLibrary(pChar('E:/ProfitSky/Dll/QueryDialog/QueryDialog.dll'));

    @GetExecuteSingleRowValue := GetProcAddress(LibHandle,'GetExecuteSingleRowValue');

    if Assigned(GetExecuteSingleRowValue) then

    begin

      if GetExecuteSingleRowValue(Handle,ConnectionString,'select top 2 OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShipCountry from Orders',

       ivalue) then

       begin

          s:=ivalue;

          for j:=0 to length(s)-1 do

            ShowMessage(VarToStr(s[j]));

       end;

    end;

  finally

    FreeLibrary(LibHandle);

    ivalue:=null;

        s:=nil;

  end;

end;
6
Function GetExecuteMultiRowValue(ParentHandle:THandle;ConnectSql,SqlText:WideString;

out Value:OleVariant):Boolean;stdcall;

 

作用:根據傳入參數,執行SQL語句後返回查詢的單行值;執行成功返回True,否則返回False;

參數說明:

    ParentHandle      THandle      ----- 調用此函數的程序句柄; 

    ConnectSql        WideString    ----- 數據庫連接字符串;

    SqlText           WideString    ----- 查詢的SQL語句;

   Value           OleVariant     ----- 返回值;原型爲Array of Array of OleVariant;

 

調用實例代碼:

 

var

   i,j:Integer;

   ivalue:OleVariant;

   s:Array of Array of OleVariant;

   GetExecuteMultiRowValue:Function(ParentHandle:THandle;ConnectSql,SqlText:WideString;out Value:OleVariant):Boolean;stdcall;

begin

  try

    LibHandle := LoadLibrary(pChar('E:/ProfitSky/Dll/QueryDialog/QueryDialog.dll'));

    @GetExecuteMultiRowValue := GetProcAddress(LibHandle,'GetExecuteMultiRowValue');

    if Assigned(GetExecuteMultiRowValue) then

    begin

      if GetExecuteMultiRowValue(Handle,ADOConnection1.ConnectionString,'select top 2 OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShipCountry from Orders',

       ivalue) then

       begin

          s:=ivalue;

          for i:=0 to HIGH(s) do

          for j:=0 to length(s[i])-1 do

            ShowMessage(VarToStr(s[i][j]));

       end;

    end;

  finally

    FreeLibrary(LibHandle);

    ivalue:=null;

        s:=nil;

  end;

end;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章