2

私は dbexpress を初めて使用し、実行時に SQL ホスト名の TSQLConnection パラメーターを設定する方法がわかりません。プログラムをクライアント システムにインストールすると、開発中に入力した開発システムから TSQLConnectionHost がまだホストを読み取っています。

4

3 に答える 3

2

TSQLConnection.Paramsは typeTStringsです。つまり、Stringアイテムのセットを保持します。TSQLConnection の場合、Params は一連のName=Valueペアを保持します。ここNameで、 はパラメータ名で、Valueはそのパラメータ値です。特定のパラメータの値を読み取るには、次を使用します。

var
  s: String;
...
s := SQLConnection1.Params.Values['ParamName'];

特定のパラメータに値を割り当てるには、次を使用します。

SQLConnection1.Params.Values['ParamName'] := 'NewValue';

('ParamName' を実際のパラメーター名に置き換え、'NewValue' を実際の新しい値に置き換えます。)

于 2011-12-17T22:14:05.810 に答える
0

問題の理由は、アプリを配布する前に SQLConnection とすべてのデータセットを切断していないことです。すべきこと a) すべてのコンポーネントが接続されていないことを確認します。b) SQLConnection のパラメーターを空白に設定します。c) アプリの起動時に、ini ファイルから必要な接続パラメーターを読み取り、それらを SQLConnection に設定します。d) 接続すれば問題ありません。よろしくクリス

于 2012-03-07T16:22:11.707 に答える
0

I faced this problem a few years ago when I started developing with dbExpress. On my development machine, the databases were in location X whereas the production machines had the databases in location Y. The way I got around this was to store the physical location of the database in the registry (via a small utility program which I wrote) and then use the following code to load the correct value. The location could be stored in an INI file which would require a slight alteration to my code, but that part is less important.

procedure TDm.SQLConnection1BeforeConnect(Sender: TObject);
var
 dir: string;

begin
 with TRegIniFile.create (regpath) do   // this is where I get the physical value
  begin
   dir:= ReadString ('firebird', progname, '');
   free
  end;

 with sqlconnection1 do
  begin
   close;
   params.values['database']:= dir;
  end;
end;
于 2011-12-18T07:02:47.303 に答える