Solved

open connection string with data.mdf in appdata folder

Posted on 2010-08-13
2
856 Views
Last Modified: 2012-05-10
this is my connection string
<connectionStrings>
    <add name="EnergyConnectionString3" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\hhhhhhh\Desktop\energy\App_Data\databasename.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>

and it works fine but how do i shorten the path can i say just app_data/databasename.mdf instead of that whole string so that when i bring it to other computer it works just fine? thanks.
0
Comment
Question by:StewSupport
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 33434679
You should be able to use:

   
<connectionStrings>
    <add name="EnergyConnectionString3" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\databasename.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

Open in new window

0
 

Author Closing Comment

by:StewSupport
ID: 33434847
thanks a million
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question