TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
salooraja
NA
12
0
C#: Need help with reading connection string from file
Nov 6 2003 2:45 PM
Hi, I am using VS.NET 2003 and C#. I am trying to create a SqlConnection by reading in the connection string from a text file. But this does not seem to work. I would really appreciate some help as to how I can accomplish this task. Here is my example code: FileStream fs = new FileStream(@"C:\connPath.txt" , FileMode.Open, FileAccess.Read); StreamReader m_streamReader = new StreamReader(fs); path = m_streamReader.ReadLine(); SqlConnection sqlConn = new SqlConnection(path); ******* If I use the following it works just fine: path = "data source = Saloo\\VSdotNET;database=Test_DB;trusted_connection=yes"; SqlConnection sqlConn = new SqlConnection(path); ******* I have no clue at this moment as to how to fix this problem. I would really appreciate some help. Thanks P.S. I have checked the string variable, it does pick up the connection string from the file but when I assign it to the SqlConnection it crashes.
Reply
Answers (
5
)
guid
C# & Access Memo fields - RTF