我这样写完以后DELPHI提示"无效的授权说明"
错误行指向工程文件的  "Application.Run;"procedure TForm1.FormCreate(Sender: TObject);
var myinifile:Tinifile;
    server,dbname,username,password,path:string;
    connection:string;
begin     //myinifile:=Tinifile.Create(qxconfig.ini);
     MyIniFile:=TIniFile.Create(path);
    try    path:=ExtractFilePath(Application.ExeName)+'qxconfig.ini';
    Server:=MyIniFile.ReadString('DB','server','');
    UserName:=MyIniFile.ReadString('DB','username','');
    Password:=MyIniFile.ReadString('DB','Password','');
    dbname:=MyIniFile.ReadString('DB','dbname','');
  finally
    MyIniFile.Free;
  end;
   connection:='Provider=SQLOLEDB.1;Password='+password;
   connection:=connection+';Persist Security Info=True;User ID='+username;
   connection:=connection+';Initial Catalog='+dbname;
   connection:=connection+';Data Source='+server;
   connection:=connection+';Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096';
   connection:=connection+';Workstation ID=BEIJINGB-SERVER;Use Encryption for Data=False;Tag with column collation when possible=False';   adoconnection1.Connected:=false;
   adoconnection1.ConnectionString:=connection;
   adoconnection1.Connected:=true;
end;我的INI文件是这样写的
[DB]
Password=capslock;
server=BEIJINGB-SERVER;
dbname=bjpgtotal;
username=sa;

解决方案 »

  1.   

    path:=ExtractFilePath(Application.ExeName)+'qxconfig.ini';
    放到
    MyIniFile:=TIniFile.Create(path);前面就Ok了
      

  2.   

    MyIniFile:=TIniFile.Create(path);//执行这句的时候path还没初始化呢
      

  3.   

    你的INI文件的数据是以分号结尾,
    连接字符串:connection:=connection+';Persist Security Info=True;User ID='+username;
    ';Persist....'前面又有分号,重复了,可能问题是在这里。
    试一下将INI文件里的分号去掉。