Reputation: 2814
I am transfering a Silverlight Application in Visual Studio 2010 from my old computer to my new computer, as I will no longer be programming on my old computer.
As I do not know how to transfer databases, I have completely remade the database on my new computer in MS Server 2008 R2.
When I load the Management Studio of Server 2008 R2, the 'Connect To Server' Dialog Box is accessed with the following info:
Server Type: Database Engine
Server Name: COMPUTER\SQLEXPRESSR2
Authentication: Windows Authentication
Username: jonas_000 [This is greyed out]
Password: [This is blank and greyed out]
Once it connects you can find my database under the 'Databases' tab and it is labeled 'MyDatabase'.
So when I go into my Visual Studio 2010 Express Silverlight project and look in the 'Database Explorer' pane, I have connected to this R2 database and it shows 'computer\sqlexpressr2.MyDatabase.dbo', and I can see all the tables I have created.
Now the Question.
In my project's Web.config file I have the following (which is for the OLD computer's setup):
<connectionStrings>
<add name="mydatabaseConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Admin\Documents\DB_MyWebSite.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
What should my new connectionStrings look like?
I cannot even see a mdf file on my new computer relating to MyDatabase.
Upvotes: 0
Views: 669
Reputation: 682
Try this:
<connectionStrings>
<add name="mydatabaseConnectionString" connectionString="Data Source=COMPUTER\SQLEXPRESSR2;Initial Catalog=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
or
<connectionStrings>
<add name="mydatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESSR2;Initial Catalog=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
or
<connectionStrings>
<add name="mydatabaseConnectionString" connectionString="Data Source=(local)\SQLEXPRESSR2;Initial Catalog=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
The providerName attribute may be optional.
Also, you should run your app as jonas_000 for this to work (which is probably what you do when pressing F5 in Visual Studio).
Upvotes: 1