主题:ADOConnection1通过读INI连接提示:“无效的授
各位好 问题如标题 代码如下
procedure TForm1.BitBtn1Click(Sender: TObject);//以下为保存INI代码 经测试OK
begin
if radiobutton1.Checked=true then//这里是SQL的NT认证模式
begin
inifile:=Tinifile.Create(ExtractFilePath(Paramstr(0))+'myini.ini');
inifile.WriteString('SQL','name','');
inifile.WriteString('SQL','password','');
inifile.Destroy;
end;
if radiobutton2.Checked=true then//这里是SQL的SA密码认证模式
begin
inifile:=Tinifile.Create(ExtractFilePath(Paramstr(0))+'myini.ini');
inifile.Writestring('SQL','name',EDIT1.TEXT);
inifile.WriteString('SQL','password',EDIT2.TEXT);
inifile.Destroy;
end;
end;
以下为设定ADO连接代码 我是通过 判断name是否为空来确定用户选定的SQL登陆方式(不知此法是否妥当?)
......
var
s1,s2:string;
ini:TIniFile;
begin
ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'myini.INI' ));
s1:= ini.ReadString('SQL','name','');
if s1='' then
begin
if ADOConnection1.Connected then ADOConnection1.Connected := False;
ADOConnection1.ConnectionString :='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=false;Initial Catalog=master;data source=(local)';
ADOConnection1.Connected := True;
end;
if s1<>'' then
s2:=ini.ReadString('SQL','password','');
begin
if ADOConnection1.Connected then ADOConnection1.Connected := False;
ADOConnection1.ConnectionString :='Provider=SQLOLEDB.1;Persist Security Info=true;User ID='+s1+';password='+s2+';Initial Catalog=master;data source=(local);';
ADOConnection1.Connected := True;
end;
......
ini.Destroy;
end;
运行后 提示:“无效的授权说明”
我估计应该是ADOConnection1.ConnectionString 这里出了问题 但不明其理 能否指点 感谢
procedure TForm1.BitBtn1Click(Sender: TObject);//以下为保存INI代码 经测试OK
begin
if radiobutton1.Checked=true then//这里是SQL的NT认证模式
begin
inifile:=Tinifile.Create(ExtractFilePath(Paramstr(0))+'myini.ini');
inifile.WriteString('SQL','name','');
inifile.WriteString('SQL','password','');
inifile.Destroy;
end;
if radiobutton2.Checked=true then//这里是SQL的SA密码认证模式
begin
inifile:=Tinifile.Create(ExtractFilePath(Paramstr(0))+'myini.ini');
inifile.Writestring('SQL','name',EDIT1.TEXT);
inifile.WriteString('SQL','password',EDIT2.TEXT);
inifile.Destroy;
end;
end;
以下为设定ADO连接代码 我是通过 判断name是否为空来确定用户选定的SQL登陆方式(不知此法是否妥当?)
......
var
s1,s2:string;
ini:TIniFile;
begin
ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'myini.INI' ));
s1:= ini.ReadString('SQL','name','');
if s1='' then
begin
if ADOConnection1.Connected then ADOConnection1.Connected := False;
ADOConnection1.ConnectionString :='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=false;Initial Catalog=master;data source=(local)';
ADOConnection1.Connected := True;
end;
if s1<>'' then
s2:=ini.ReadString('SQL','password','');
begin
if ADOConnection1.Connected then ADOConnection1.Connected := False;
ADOConnection1.ConnectionString :='Provider=SQLOLEDB.1;Persist Security Info=true;User ID='+s1+';password='+s2+';Initial Catalog=master;data source=(local);';
ADOConnection1.Connected := True;
end;
......
ini.Destroy;
end;
运行后 提示:“无效的授权说明”
我估计应该是ADOConnection1.ConnectionString 这里出了问题 但不明其理 能否指点 感谢