none
what is my dbname? RRS feed

  • Question

  •  

    In visual studio I created a database, made some tables, connected to the database in my web services...everything works fine on my local desktop (using sqlexpress).

     

    Then I copied the .mdf and .ldf file up to my hosted website which is using sql server 2005.

     

    CREATE DATABASE permission denied in database 'master'.
    Could not attach database '' to file 'C:\Inetpub\vhosts\mycooldomain.com\subdomains\services\httpdocs\App_Data\aspnetdb.mdf'.

     

    I'm confused.   Its a db file is there name?  I've tried a number of varations in the connection string with no results

     

    connectionString="data source=localhost;Integrated Security=SSPI;AttachDBFilename=C:\Inetpub\vhosts\mycooldomain.com\subdomains\services\httpdocs\App_Data\aspnetdb.mdf;;Integrated Security=True;User Instance=false"

     

    connectionString="data source=localhost;Integrated Security=SSPI;AttachDBFilename=C:\Inetpub\vhosts\mycooldomain.com\subdomains\services\httpdocs\App_Data\aspnetdb.mdf;;Integrated Security=True;User Instance=true"

     

    connectionString="data source=localhost;Integrated Security=SSPI;AttachDBFilename=C:\Inetpub\vhosts\mycooldomain.com\subdomains\services\httpdocs\App_Data\aspnetdb.mdf;Database=aspnetdb.mdf;User Instance=false"

     

    help! please!  lol

     

    Matt

     

     

     

     

     

     

     


     

    Wednesday, September 24, 2008 6:36 PM

All replies

  • I believe, by default, web applications do not have permissionas to access absolute folders. Everything is limited to virtual path. Try next connection string (you need to replace YourDatabaseServer with the actual database server name)

     

    connectionString="AttachDbFileName=|DataDirectory|\aspnetdb.mdf;integrated security=SSPI;Data Source=YourDatabaseServer;User Instance=true;"

     

    Thursday, September 25, 2008 9:52 AM
    Moderator
  • I tried that one too.   I got a different error:   Invalid value for key 'attachdbfilename'

     

     

    Matt

    Thursday, September 25, 2008 2:15 PM
  • Can you post exact code that you are using to attach to and open database connection?

     

    Friday, September 26, 2008 9:52 AM
    Moderator
  • I stuck with a fairly basic implementation:

     

    string connectStr = ConfigurationManager.ConnectionStrings["securityDB"].ConnectionString;

    SqlConnection connection = null;

    SqlCommand cmd = null;

    User record = null;

    using (connection = new SqlConnection(connectStr))

    {

    connection.Open();

    string sql = "SELECT .....";

    using (cmd = new SqlCommand(sql, connection))

    {

     

     

     

    Matt

    Friday, September 26, 2008 12:39 PM