dll 代码uses
Windows, StrUtils, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB, DB, DBCtrls, ExtCtrls, Grids, DBGrids;
{$R *.res}
var
dataPath:string;
ADOQuery: TADOQuery;begin
dataPath:= ExtractFilePath(ParamStr(0));
while RightStr(dataPath, 1) <> '\' do
begin
dataPath := dataPath + '\';
end;
ADOQuery:=TADOQuery.Create(nil);// 查看在这死机,我想应该是没有初始化,单不知道在那里初始,加什么代码
ShowMessage('2');
ADOQuery.ConnectionString:= 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=MS Access Database;Initial Catalog=' + dataPath + 'data.mdb';
With ADOQuery do
begin
ShowMessage('3');
Close;
SQL.Clear;
SQL.Add('Select type,path From path');
Open;
ShowMessage('kkkkkk');
SQL.Clear;
Close;
end;
ADOQuery.ConnectionString:='';end.
Windows, StrUtils, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB, DB, DBCtrls, ExtCtrls, Grids, DBGrids;
{$R *.res}
var
dataPath:string;
ADOQuery: TADOQuery;begin
dataPath:= ExtractFilePath(ParamStr(0));
while RightStr(dataPath, 1) <> '\' do
begin
dataPath := dataPath + '\';
end;
ADOQuery:=TADOQuery.Create(nil);// 查看在这死机,我想应该是没有初始化,单不知道在那里初始,加什么代码
ShowMessage('2');
ADOQuery.ConnectionString:= 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=MS Access Database;Initial Catalog=' + dataPath + 'data.mdb';
With ADOQuery do
begin
ShowMessage('3');
Close;
SQL.Clear;
SQL.Add('Select type,path From path');
Open;
ShowMessage('kkkkkk');
SQL.Clear;
Close;
end;
ADOQuery.ConnectionString:='';end.
begin
dataPath := dataPath + '\';
end;
begin
dataPath := dataPath + '\';
end;
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
Windows, StrUtils, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB, DB, DBCtrls, ExtCtrls, Grids, DBGrids;
{$R *.res}
var
ADOQuery: TADOQuery;begin
ShowMessage('1');
ADOQuery:=TADOQuery.Create(nil);
ShowMessage('2');
With ADOQuery do
begin
ADOQuery.ConnectionString:= 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=MS Access Database;Initial Catalog=D:\data.mdb';
Close;
SQL.Clear;
SQL.Add('Select type,path From path');
Open;
ShowMessage('kkkkkk');
SQL.Clear;
Close;
end;
end.
还是不行,吓我一跳。还是到ADOQuery:=TADOQuery.Create(nil);这步死机。前面的别看,我只是在测试,通过了在修改
ADOQuery当做参数传进来吧,省的创建的时候死掉了
CoInitialize(nil);
try
ADOQuery:=TADOQuery.Create(nil);
finally
CoUninitialize;
end;