Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,

I've a connection string in WeB.Config file
<appsettings>
C#
<add key="Excel03ConString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR={0};'"/>

Now i have to get the full connection string with the filename
connectionString = ConfigurationManager.AppSettings["Excel03ConString"].ToString();

This is retrieving the same connection string mentioned in the web.config file but i want with filename specified, how to do?
Posted
Comments
Thanks7872 11-Jun-13 7:15am    
Which filename are you talking about?can you elaborate more on this?

1 solution

C#
String connectionString = ConfigurationManager.AppSettings["Excel03ConString"];
String fileName         = ConfigurationManager.AppSettings["FileName"]; // Or take it from a database or where ever

connectionString = String.Format(connectionString, fileName);


Regards,
— Manfred
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900