请问哪位知道怎么把这个字符串以分号为界分别负给一个数组呀?
str:=Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=gz;Data Source=YYY;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=YYY;Use Encryption for Data=False;Tag with column collation when possible=False
也就是使array[1]=Provider=SQLOLEDB.1,array[2]=Persist Security Info=False
这应该怎么做呀?

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      str:string;
      strarr:array[0..10]of string;
      i,j:integer;
    begin
      str:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=gz;Data Source=YYY;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=YYY;Use Encryption for Data=False;Tag with column collation when possible=False';
      i:=0;
      j:=Pos(';',str);
      while (j>0) do
      begin
        strarr[i]:=Copy(str,1,j-1);
        str:=Copy(str,j+1,Length(str)-j);
        j:=Pos(';',str);
        ShowMessage(strarr[i]);
        inc(i);
      end;
      strarr[i]:=str;
      ShowMessage(strarr[i]);
    end;