unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
DB, ADODB, DBCtrls;
type
TForm2 =
class(TForm)
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
DBLookupComboBox1: TDBLookupComboBox;
private
{ Private-Deklarationen }
public
procedure setConnection(DBPfad:
String);
function OpenTable(TableName:
String): Boolean;
function getFastDBColumn(TableName:
String; colTitle:
String):
String;
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
////////////////////////////////////////////////////////////////////////////////
// Zusammenbau des Connection-Strings
//
procedure TForm2.setConnection(DBPfad:
String);
var conString: WideString;
begin
conString := '
Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;';
conString := conString +'
Data Source='+ DBPfad+'
;';
conString := conString +'
Mode=Share Deny None;Extended Properties="";';
conString := conString +'
Persist Security Info=False;';
conString := conString +'
Jet OLEDB:System database="";';
conString := conString +'
Jet OLEDB:Registry Path="";';
conString := conString +'
Jet OLEDB:Database Password="";';
conString := conString +'
Jet OLEDB:Engine Type=5;';
conString := conString +'
Jet OLEDB:Database Locking Mode=1;';
conString := conString +'
Jet OLEDB:Global Partial Bulk Ops=2;';
conString := conString +'
Jet OLEDB:Global Bulk Transactions=1;';
conString := conString +'
Jet OLEDB:New Database Password="";';
conString := conString +'
Jet OLEDB:Create System Database=False;';
conString := conString +'
Jet OLEDB:Encrypt Database=False;';
conString := conString +'
Jet OLEDB:Don''
t Copy Locale on Compact=False;';
conString := conString +'
Jet OLEDB:Compact Without Replica Repair=False;';
conString := conString +'
Jet OLEDB:SFP=False ';
try
ADOConnection1.ConnectionString := conString;
// 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+DataSource+';Mode=Share Deny None;Extended Properties="";Persist Security Info=False;Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Dont Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False';
except
end;
end;
///////////////////////////////////////////////////////////////////////////////
// öffnet die Tabelle "TableName"
function TForm2.OpenTable(TableName:
String): Boolean;
var field: TField;
begin
field := TField.Create( self );
//ADOTable := TADOTable.Create(self);
ADODataSet1 := TADODataSet.Create(self);
ADODataSet1.Close;
end;
////////////////////////////////////////////////////////////////////////////////
//
function TForm2.getFastDBColumn(TableName:
String; colTitle:
String):
String;
var field: TField;
Str:
String;
DataSet: TADODataSet;
begin
// OpenDatabase;
DataSet := TADODataSet.Create(self);
DataSet.Connection := ADOConnection1;
if DataSet =
nil then
OpenTable(TableName);
DataSet.CommandText := '
SELECT ['+colTitle+'
] FROM '+TableName+'
' ;
DataSet.Open;
field := DataSet.Fields[0];
Str := field.Text;
result := str;
end;
end.