[oledb]
; Everything after this line is an OLE DB initstring
Provider=SQLOLEDB.1;Password=topcomputer;Persist Security Info=True;User ID=sa;Initial Catalog=FLSystem;Data Source=nt04
如何把上面的數據庫連接的字符串讀取出來,以上是一個*.udl文件。Provider=SQLOLEDB.1;Password=topcomputer;Persist Security Info=True;User ID=sa;Initial Catalog=FLSystem;Data Source=nt04

解决方案 »

  1.   

    如何把*.udl文件中的數據庫連接字符串用c#代碼讀出來 ,*.udl是delphi中常用到的配置數據庫連接的工具。
      

  2.   

    string oldstr="[oledb]; Everything after this line is an OLE DB initstring Provider=SQLOLEDB.1;Password=topcomputer;Persist Security Info=True;User ID=sa;Initial Catalog=FLSystem;Data Source=nt04";string newstr = oldstr.Substring(oldstr.IndexOf("Provider"), oldstr.Length - oldstr.IndexOf("Provider"));
          
    //验证通过
      

  3.   

    方法二,正则表达式using System.Text.RegularExpressions;string oldstr="[oledb]......";string newstr = Regex.Match(oldstr, "Provider[^]]+").ToString();//验证通过
      

  4.   

    Provider=SQLOLEDB.1;Password=topcomputer;Persist Security Info=True;User ID=sa;Initial Catalog=FLSystem;Data Source=nt04
    是永远放在文件的最末端吗?
      

  5.   

    [oledb]
    ; Everything after this line is an OLE DB initstring
    Provider=SQLOLEDB.1;Password=topcomputer;Persist Security Info=True;User ID=sa;Initial Catalog=FLSystem;Data Source=nt04
    如何把上面的數據庫連接的字符串讀取出來,以上是一個*.udl文件。
      

  6.   

    應是放在最後面
    Provider=SQLOLEDB.1;Password=topcomputer;Persist Security Info=True;User ID=sa;Initial Catalog=FLSystem;Data Source=nt04