-1
// set up connection to the database
        myConnection = new System.Data.SqlClient.SqlConnection();
        myConnection.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Craig\\Desktop\\Project\\App_Data\\ASPNETDB.MDF;Integrated Security=True;User Instance=True;";

Hi this is my above connection string which works fine on my personal computer. I need to move the entrive Project folder to a different location which will not have access to the current address.
Could someone be so kind to invoke the server.mappath method into my string. I have tried my self but failed misserably.

I need a fast reponse

ty

Votes + Comments
Urgent! Do not use that word. Please.
5
Contributors
12
Replies
13
Views
8 Years
Discussion Span
Last Post by dnanetwork
0

// set up connection to the database
myConnection = new System.Data.SqlClient.SqlConnection();
myConnection.ConnectionString = " copy and past path only";


you know how can you get path ?
ok i will explain
1) go to tools and add sqldatasource
2) you can see small ->(arrow) in sql data source in your aspx form then go in configrationdata string
3) one dialogbox open select your data based if not in dropdown list then go in new connection string ......
4) you can see path in +connectionstring
copy the path and past myConnection.ConnectionString = " copy and past path only" add / in every place in path ok

Thanks
Jignesh Ahya
Ahmedabad

0

Hi, ive done just as you said and i still get error! maybee it because i not slept for two days but its frustrating.

Mayb if i post the string

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True

You can solve?

0

This is not Right

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True

Go to get the Path and show it to use and we will tell you how to fit in the connection string

0

im not sure what you mean?
Is this not as easy i think to change?
"Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Craig\\Desktop\\Project\\App_Data\\ASPNETDB.MDF;Integrated Security=True;User Instance=True;";

0

So what you mean is that is you go to explorer and paste this

C:\\Users\\Craig\\Desktop\\Project\\App_Data\\

It shows you the Folder with ASPNETDB.MDF File ? please Confirm

0

Yes the database works fine on my local machine, however I need the string to point to a relative location rather than specific file. I basically need to burn the folder to disc and with teh current string the connection will be looking for the folder on my c:/..

0

You what you want exactly is that you want to change the Connection-string without recompiling your application because the Connection string might change at anytime ?

0

I just want the connection string to map the server path.
It should not be point to a specific file location.

I am sorry you cannot understand

0

Use |DataDirectory|.

myConnection = new System.Data.SqlClient.SqlConnection();
myConnection.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True;";
1

my friend this is not gonna work...

cos u r using the database in the appdata folder which got created..

using asp.net configuration wizard...if you are moving the stuff in to new machine then you need to do configure again that database using asp.net configuration wizard..

i hope this will help...i had the same situation 6 month ago..

Votes + Comments
N.A
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.