I'm really having hard time importing ASPNETDB.mdf to remote server running sqlserver 2005..
I'm using sql server express edition (along with visual web developer 2008)
I use the same string

<add name="aspnetusers" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"   providerName="System.Data.SqlClient" />

No connection can be established....

Then I changed that to

<add name="aspnetusers" 
connectionString="server=(local);AttachDBFilename=ASPNETDB.mdf;Integrated Security=True;"  providerName="System.Data.SqlClient"/>

I gives error
CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file ASPNETDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I even copied(replicated) entire database to my remote server
but some stupid schematic version problem arises....

My control panel is PLESK

Please help me out how to fix this common problem....

Dani AI

Generated

The error messages shown in the thread mean SQL Server attempted to create/attach a database and the account doing that does not have the required rights. On hosted/Plesk servers this is common: AttachDbFilename and SQL Express "user instances" work on a local developer machine, but most hosts disable database creation/attach for shared accounts. was correct about permissions, hit the same constraint, and ’s successful approach (publishing a .sql script and executing it) is the normal workaround.

Recommended, reliable workflow:

  • Create a normal SQL Server database using the Plesk control panel (Databases → Add Database) so the host provisions the DB and login.
  • Populate that database with the ASP.NET membership schema. Use the Microsoft tool aspnet_regsql.exe (located in the Framework folder) or generate a full schema+data script with the SQL publishing tools and run it on the hosted server. Example command lines (run from a prompt on a machine that has .NET installed):
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe -S serverName -U sqlUser -P sqlPassword -d databaseName -A all

%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe -S serverName -E -d databaseName -A all
  • Change the application to use a server-based connection (server + database + credentials) instead of attaching a file. As suggested, pointing directly at the hosted DB is the correct pattern for production.

Troubleshooting notes and cautions:

  • If the MDF was created by a newer SQL Server than the host provides, you cannot attach it to an older engine—generate scripts targeted at the host version.
  • MDF/LDF files must be on a local disk and accessible to the SQL Server service; UNC paths and files in use will fail.
  • If the host will not allow you to run scripts, give them the generated .sql or a .bak and request they restore/attach it for you (they need sysadmin rights to do the attach).

The approach used by (publish a T-SQL script and execute it) is a robust, host-friendly deployment method and avoids the permission and attach problems described in the thread.

I'm really having hard time importing ASPNETDB.mdf to remote server running sqlserver 2005..
I'm using sql server express edition (along with visual web developer 2008)
I use the same string
<add name="aspnetusers" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
No connection can be established....

Then I changed that to
<add name="aspnetusers"
connectionString="server=(local);AttachDBFilename=ASPNETDB.mdf;Integrated Security=True;" providerName="System.Data.SqlClient"/>
I gives error
CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file ASPNETDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I even copied(replicated) entire database to my remote server
but some stupid schematic version problem arises....

My control panel is PLESK

Please help me out how to fix this common problem....

Hi,
After great search and hours of hit 'n trials ...I'm able to solve the problem...Just use C# to run .sql script generated after publishing the database using sql publishing wizard and run it using C# script..
If anyone want that...do ask me...

commented: thanks for offering +0

I'm really having hard time importing ASPNETDB.mdf to remote server running sqlserver 2005..
I'm using sql server express edition (along with visual web developer 2008)
I use the same string
<add name="aspnetusers" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
No connection can be established....

Then I changed that to
<add name="aspnetusers"
connectionString="server=(local);AttachDBFilename=ASPNETDB.mdf;Integrated Security=True;" providerName="System.Data.SqlClient"/>
I gives error
CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file ASPNETDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I even copied(replicated) entire database to my remote server
but some stupid schematic version problem arises....

My control panel is PLESK

Please help me out how to fix this common problem....

do you have permissions on this remote machine to create a database. you will need an account which has the nescessary permissions to auto generate a db.

commented: nice pic +0

do you have permissions on this remote machine to create a database. you will need an account which has the nescessary permissions to auto generate a db.

Hello. Iam having the same problem

CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file C:\Inetpub\vhosts\\httpdocs\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

What to do? Iam also using PLESK.

System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file C:\Documents and Settings\Sameer\Local Settings\Apps\2.0\Data\Z4YBX7D1.JK1\3WBWYJDK.EO3\sqlc..tion_6a5ad26de079ed06_0001.0000_a62e43de303e0b3a\Data\GCTMS_Data.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

PLEASE HELP FOR THIS ERROR.

Hi

This code is provide the connection of ASPNETDB.mdf.You can refer it.

<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
    connectionString= "Server=SQL_SERVER_ADDRESS,1433;Database= DATABASE_NAME;User=SQL_USERNAME;Password=SQL_PASSWORD;"
    providerName="System.Data.SqlClient" />
</connectionStrings>

If you want to more detail about ASPNETDB.mdf than refer this following link.

http://www.studiocoast.com.au/knowledgebase/6/aspnet/using-sql-server-instead-of-aspnetdbmdf.aspx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.