0
votes

ok my ASP.net website is running as long I do not use the database. I guess the problem is that I do not really understand the setup of the connectionstring and struggle do find the correct answer.

My connection string looks like this: "ConnectionStrings" "Add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=aspnetdb;AttachDbFilename=|DataDirectory|\aspnetdb.mdf;Integrated Security=SSPI" providerName="System.Data.SqlClient" /" "add name="ApplicationServices" connectionString="Data source=.;Integrated Security=True;Initial Catalog=aspnetdb" /" "/connectionStrings"

===> I had to change the code as it wouldn't display otherwise (sorry)

When I run the application and want to login on localhost I get the following error: (website is on the server versus SQL is on the C drive installed):

Database 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\aspnetdb.mdf' already exists. Choose a different database name. Cannot attach the file 'S:\H-L\legaldocsnsw\WebSite1\App_Data\aspnetdb.mdf' as database 'aspnetdb'.

On the internet there is a database master and my database I created CID05220_aspnetdb: CREATE DATABASE permission denied in database 'master'. Cannot attach the file 'C:\inetpub\vhosts\legaldocsnsw.com.au\httpdocs\App_Data\aspnetdb.mdf' as database 'aspnetdb'.

How do I have to change the connection string to access these either locally or on the net. Could someone please help and maybe even explain what I am doing wrong please?

Kind Regards, Rene

1
what does your connection string look like?attila
it seems more a permissoj issue to me rather than the connection stringpedrommuller
changed it in the text as it would display with the open and close tagsRene

1 Answers

1
votes

Do you want to use a database that is permanently attached to the SQL Server instance or do you want to attach an MDF file at run time? If you want to do the former then get rid of the AttachDbFilename attribute in your connection string. If you want to do the former then you will need a SQL Server Express instance or LocalDB installed on the same machine as the application.