Search code examples
sqlasp.netvb.netvisual-studio-2017web-publishing

Website connectionstring


My asp.net vb website works fine on my pc in Visual Studio 2017.

My local connection strings are:

  <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-VF-20150414155129;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-VF-20150414155129.mdf" />
  <add name="VIConnectionString1" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Renaissance.mdf;Integrated Security=True;User Instance=True"  />

When I upload web.config I use:

<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;AttachDBFilename=|DataDirectory|\aspnet-VF-20150414155129.mdf;Initial Catalog=aspnet-VF-20150414155129;User Id=vflogin;Password=mypassword" />
<add name="VIConnectionString1" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Renaissance.mdf;Initial Catalog=Renaissance.mdf;User Id=vf_vi;Password=mypassword" />

The error message I get is when I access a webpage that tries to use the database:

CREATE DATABASE permission denied in database 'master'.

When I access a webpage that does not use the database it works fine.

I've spent three days on this. The site is hosted by Netcetera but their "tech support" seems to know considerably less than me.

If any guru out there can answer this it would be much appreciated.


Solution

  • The problem is caused because of this part of the connection string :

    AttachDBFilename=|DataDirectory|\aspnet-VF-20150414155129.mdf

    ASP.Net is trying to create a new database. You should create the database or restore a backup, remove the string above and try again.

    Your hosting provider had to give you access to the cPanel, so you can check your database settings anytime. I say this because this part won't work either

    Data Source=.\SQLEXPRESS <-- this is your PC. You need the SQL Server Intance settings provided by Netcetera