Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

open connection string with data.mdf in appdata folder

Posted on 2010-08-13
2
Medium Priority
?
875 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

971 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