我是动态生成ADOConnection,但执行程序时,老出现尚未调用CoInitialize错误。
解决方案 »
- ibOwnerDrawFixed和ibStandard是什么意思啊??
- 求助是不是有一套组件叫RM啊?哪里有下载尼?
- 求做报表的源代码
- 一个偶尔出现的问题,需要解决一下!
- 如何为ClientDataset建立索引?(第N次提问)
- 请教高手如何在任务栏中不可看到自己的程序!(老板让管理下属部门的软件机器但要看不到)!
- 打算用D6为前任的VFP做的软件加功能,用ADO连接他的数据库,VFP的数据库文件名字是怎样的
- 热键
- HELP ME!关于WEBBROWSER的一个问题。
- 各位大哥,请问如何用鼠标控制进度条(ProgressBar)?
- 提问000
- 也请关注:特别是伴水老师要帮我看一下这两个贴子的问题???????
with ADOConnectionUserDatabase do
begin
//Connected:=True;
ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog='+strUserDB+';Data Source=(local);';
KeepConnection := False;
LoginPrompt := False;
Mode := cmReadWrite;
Provider := 'SQLOLEDB.1';
Open;
end;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Db, DBTables, Grids, DBGrids, ComCtrls, ADODB;type
TForm1 = class(TForm)
Button1: TButton;
ADOConnection1: TADOConnection;
procedure Button1Click(Sender: TObject);
private
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var
tempCon: TADOConnection;
tempStr: string;
begin
tempStr := 'xxxx'; //此处加入数据库连接字符串
tempCon := TADOConnection.Create(Self);
with tempCon do
begin
Connected := false;
ConnectionString := '';
ConnectionString := tempStr;
try
Connected := true;
ShowMessage('Succeed!');
except
ShowMessage('Failed!');
Exit;
end;
end;
//.... 其它处理过程
end;end.
ADOConnectionSystemDatabase 是在private中定义的。strConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog='+strSystemDB+';Data Source=(local);';
with ADOConnectionSystemDatabase do
begin
Connected:=False;
ConnectionString:='';
ConnectionString:=strConnectionString;
KeepConnection := False;
LoginPrompt := False;
Mode := cmRead;
Provider := 'SQLOLEDB.1';
try
Connected:=True;
Except
LogMessage('无法联接到数据库'+strSystemDB+'。',EVENTLOG_ERROR_TYPE);
end;
end;
不知道还有什么问题。总是老样子的错误提示。