首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

難者不會,會者不難,請教一個簡單的從文件中取字串的問題

2012-01-06 
難者不會,會者不難,請教各位高手一個簡單的從文件中取字串的問題。[oledb]EverythingafterthislineisanOLE

難者不會,會者不難,請教各位高手一個簡單的從文件中取字串的問題。
[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
是永远放在文件的最末端吗?

热点排行