我发现毛病了, 可是还是解决不了
我在Com中定义了一个方法
procedure TCoMenuQuery.SetConnectionString(const sConnString: WideString);
begin
adocMenuQuery.Close;
adocMenuQuery.ConnectionString := sConnString;
adocMenuQuery.Open;
end;
我在客户端中调用
procedure TForm1.SetConnections(sConnString: String);
begin
FSysParams.ConnectionString := sConnString;
scMenuQuery.Close;
scMenuQuery.Address := '192.168.10.27';
scMenuQuery.Port := 211;
scMenuQuery.ServerName := 'Menu.CoMenuQuery';
scMenuQuery.Open;
scMenuQuery.AppServer.SetConnectionString(sConnString);
end;
这样调用会在scMenuQuery.AppServer.SetConnectionString(sConnString);处报'无效的授权说明'的错误
但是我如果改成
procedure TForm1.SetConnections(sConnString: String);
begin
FSysParams.ConnectionString := sConnString;
scMenuQuery.Close;
scMenuQuery.Address := '192.168.10.27';
scMenuQuery.Port := 211;
scMenuQuery.ServerName := 'Menu.CoMenuQuery';
scMenuQuery.Open;
scMenuQuery.AppServer.SetConnectionString('Provider=SQLOLEDB.1;Password=jackson;Persist Security Info=True;User ID=sa;Initial Catalog=Weight;Data Source=heaven');
end;
就不会报错,而且我两次传的参数的值都是一样的
而且在调用
procedure TForm1.SetConnections(sConnString: String);
begin
FSysParams.ConnectionString := sConnString;
scMenuQuery.Close;
scMenuQuery.Address := '192.168.10.27';
scMenuQuery.Port := 211;
scMenuQuery.ServerName := 'Menu.CoMenuQuery';
scMenuQuery.Open;
scMenuQuery.AppServer.SetConnectionString(sConnString);
end;
这个过程时,如果直接写成
SetConnections('Provider=SQLOLEDB.1;Password=jackson;Persist Security Info=True;User ID=sa;Initial Catalog=Weight;Data Source=heaven');
也不会报错
但是写成
l_sConnectString := 'Provider=SQLOLEDB.1;';
l_sConnectString := l_sConnectString + 'Password=' + l_sPassword + ';';
l_sConnectString := l_sConnectString + 'Persist Security Info=True;';
l_sConnectString := l_sConnectString + 'User ID=' + l_sUserID + ';';
l_sConnectString := l_sConnectString + 'Initial Catalog=' + l_sDataBase + ';';
l_sConnectString := l_sConnectString + 'Data Source=' + l_sServerIP;
SetConnections(l_sConnectString);
就又报'无效的授权说明'的错误
我不知道怎么回事,郁闷的不行了,望众大虾们赐教