難者不會,會者不難,請教各位高手一個簡單的從文件中取字串的問題。
[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
------解决方案--------------------正则表达式应该可以实现吧
------解决方案--------------------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 "));
//验证通过
------解决方案--------------------Provider=SQLOLEDB.1;Password=topcomputer;Persist Security Info=True;User ID=sa;Initial Catalog=FLSystem;Data Source=nt04
是永远放在文件的最末端吗?