Solved

open connection string with data.mdf in appdata folder

Posted on 2010-08-13
2
860 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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