473,322 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

I need solution for read connection string from text file

this code for aspx.cs:

Expand|Select|Wrap|Line Numbers
  1.  string inputString;
  2.         resultLabel.Text = "";
  3.         using (StreamReader streamReader = File.OpenText(@"E:\projects\readtxt\nan.txt"))
  4.         {
  5.             inputString = streamReader.ReadLine();
  6.             while (inputString != null)
  7.             {
  8.                 resultLabel.Text += inputString + "<br />";
  9.                 inputString = streamReader.ReadLine();
  10.             }
  11.         }
text file contains:

string con = new SqlConnection(ConfigurationManager.ConnectionStrin gs["nandhaconnectionstring"].ConnectionString);

i get error The ConnectionString property has not been initialized.
Oct 15 '13 #1

✓ answered by Rabbit

Please use code tags when posting code or formatted data.

Reading data from a text file does not run code. You need to put the code in your source files and use the text file to supply only the string.

3 1499
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

Reading data from a text file does not run code. You need to put the code in your source files and use the text file to supply only the string.
Oct 15 '13 #2
just tell me how to do this because i am beginner to learn asp.net....
Oct 16 '13 #3
Rabbit
12,516 Expert Mod 8TB
You already know how, you just need to move the code around. It's all there.

You know how to open and read from a file. You just need to move the code out of your text file and into the rest of the source code.

In pseudo code, you need to do something like this:
Expand|Select|Wrap|Line Numbers
  1. connectionStringFromFile = read line from text file
  2. connection.connectionString = connectionStringFromFile
Where the file ONLY contains the connection string, not code.
Oct 16 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: H Brown New To It | last post by:
I am very new to Java. How would you go about making Java program that reads in a fixed length text file and pass the data into a table in an sql table? The text file data looks something like...
7
by: Tee | last post by:
Hi, I need some help here for DSN connection string. I know it's not recommended to use DSN, even I dont like it as well ... but for now, my situation is I am using a shared hosting. I do not...
1
by: Saravanan | last post by:
I need to read in a text file as strings and then write some of these strings into another text file. The output file is in the working directory while the input text file is not. how can I...
6
by: arf | last post by:
Hello, i have a problem where i need read dataset from text file and keep them into a vector. e.g. dataset: "0012 0033 00045 0044 0047" Based on this dataset, i need to keep every 4...
3
by: maylee21 | last post by:
hi, anyone can help me figure out how to read data from a text file like this: 10980012907200228082002 and extract the data according to this kind of format: Record type 1 TY-RECORD ...
2
by: JamesGeddes | last post by:
Reading from a text file on your local computer is easy, but surely using a URL to point to a different location should work too? The code I have thus far is as follows using System; using...
2
by: kino | last post by:
Hello, I am supposed to read from a text file a series of numbers and then store them in a struct array. Here's my code: int main() { ifstream In; string folder, filename, name2,...
2
by: Daniel EXBN | last post by:
Hi! I need to read a text file which has ~10K lines each line has 7 or 10 rows each row is separated by TAB the text file contains some lines which start with "//" and there is no need to...
0
by: rsduck | last post by:
My program is supposed to render graphics from the attached file. I can get my program to read the file without issue. My problem lies in getting the file to convert into graphics. I'm not even sure...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.