Wednesday, March 21, 2012

how to use SQL Express in a shared hosting environment

All--

Please help.

I have deployed my site to my shared host and I am getting the following RTE...

An attempt to attach an auto-named database for file... ..\App_Data\CommerceDB.mdf failed

...and I cannot find the issue.

Note that I have given Full-Permissions on root folder for the IUSR account and for the ASPNET account.

The full error message is below.

Anyway, do you have an suggestions?

My web hosting provider has advertised that they do support SQL Express 2005. What exactly do I need to ask them to do in order to get this working?

Please advise.

Thank you.

--Mark Kamoski

Server Error in '/mkamoski/S16' Application.
------------------------


An attempt to attach an auto-named database for file c:\hosting\webhost4life\member\mkamoski\S16\App_Data\CommerceDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file c:\hosting\webhost4life\member\mkamoski\S16\App_Data\CommerceDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Source Error:

Line 88: ''' <returns></returns>

Line 89: Public Shared Function GetCart() As ShoppingCart

Line 90: Dim rdr As IDataReader = ShoppingCartProvider.Instance.CartGetCurrentCart(GetUserName())

Line 91: Dim cart As ShoppingCart = New ShoppingCart()

Line 92: cart.Load(rdr)

Source File: c:\hosting\webhost4life\member\mkamoski\S16\App_Code\BLL\ShoppingCartManager.vb Line: 90

All--

OK. I got it. It is working.

FWIW and FYI, the site is here...

http://site291.webhost4life.com/mkamoski/S16/

...but it is just a "stock" site right now.

Anyway, here are some things that I learned.

(1). For some reason, the...

Initial Catalog=myDBName

...had to be set in Web.config for both the CommerceDB database and the ASPNET database.

(2). At my host, the database needs to have a unique name. I renamed CommerceDB to something like CommerceDB200605022058 and the same for the ASPNET database.

(3). I had to make sure that I detached the databases on my local workstation for both CommerceDB and ASPNET database BEFORE uploading.

(4). For both the CommerceDB database and the ASPNET database, I had to rename the database itself AND the actual physical files.

(5). I uploaded the *.MDF files but I could not upload the *.LDF files, at the request/suggestion of my web host and, apparently, they are correct.

After all that, it is working.

FWIW, I host athttp://www.WebHost4Life.com and I must say that I am pleased with them. It sometimes takes a little doing on my part to get things done; but, given that I am a hands-on person, I don't mind that much. What is important is that I have complete control over my site's administration, and I do with the tools they provide.

Thank you.

--Mark Kamoski


|||

mkamoski:

Hi mkamoski,

I'm having a similar issue with names.co.uk - please can you give me some more advice?

I have two empty databases set-up on the host, but these are empty - how do I copy the tables etc. from my local databses into these empty databases on the host? I am being told to us SQL Server Managment Studio Express - but I cannot see a way of copying a database from my local PC to the host.

Do you have any experience of this ? I'm going out of my mind with this one - I've been looking around for may days and still have no answer!

I'm completely new to this, so some detailed 'idiots guide' would be very welcomed.

Hoping for some advice, thanks

All--

Please help.

I have deployed my site to my shared host and I am getting the following RTE...

An attempt to attach an auto-named database for file... ..\App_Data\CommerceDB.mdf failed

...and I cannot find the issue.

Note that I have given Full-Permissions on root folder for the IUSR account and for the ASPNET account.

The full error message is below.

Anyway, do you have an suggestions?

My web hosting provider has advertised that they do support SQL Express 2005. What exactly do I need to ask them to do in order to get this working?

Please advise.

Thank you.

--Mark Kamoski

Server Error in '/mkamoski/S16' Application.
------------------------


An attempt to attach an auto-named database for file c:\hosting\webhost4life\member\mkamoski\S16\App_Data\CommerceDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file c:\hosting\webhost4life\member\mkamoski\S16\App_Data\CommerceDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Source Error:

Line 88: ''' <returns></returns>

Line 89: Public Shared Function GetCart() As ShoppingCart

Line 90: Dim rdr As IDataReader = ShoppingCartProvider.Instance.CartGetCurrentCart(GetUserName())

Line 91: Dim cart As ShoppingCart = New ShoppingCart()

Line 92: cart.Load(rdr)

Source File: c:\hosting\webhost4life\member\mkamoski\S16\App_Code\BLL\ShoppingCartManager.vb Line: 90

|||

MDH:

I'm having a similar issue with names.co.uk - please can you give me some more advice?

I have two empty databases set-up on the host, but these are empty - how do I copy the tables etc. from my local databses into these empty databases on the host? I am being told to us SQL Server Managment Studio Express - but I cannot see a way of copying a database from my local PC to the host.

Do you have any experience of this ? I'm going out of my mind with this one - I've been looking around for may days and still have no answer!

I'm completely new to this, so some detailed 'idiots guide' would be very welcomed.

Hoping for some advice, thanks

First, I must say that I am also new to SQL Server 2005 Express too, so please listen to what I say with care and with caution and with skepticism and keep my disclaimer in mind-- "beware, I don't really know what I am doing here, but I am going to TRY something".

:-)

Now, to copy database objects (not data, just the objects such as tables, views, and SPs) one can use the management tool GUI to create a script of the objects. Then, just run the scripts on the empty database and you are done. I did this for my stuff and it worked great. I also had a script of "seed data" the initializes the core data in the database. This is, I think, a great way to go during development because one can always re-initialize the database to a "clean" state, which is essential for accurate testing.

For details on the GUI tool, look for this...

SQL Server 2005 Express Edition with Advanced Services

...which should be at this link...

http://msdn.microsoft.com/vstudio/express/sql/download/

...which has...

"SQL Server Management Studio Express, a graphical management tool based on SQL Server Management Studio that makes it easy to manage and administer SQL Server Express databases"

...so that should help.

Also at that link, get the Books Online (BOL), as they will provide a lot of detail to you on-demand.

Now, as far as migrating both objects AND data, I am a bit stuck. When I tried to do this, I had an old version of the management tool (the "technonolgy preview" edition). It crashed a lot and I could not figure out how to do it. That was sad because it is very easy in SQL Server 2000. That's not to say that it cannot be done-- I am just saying that I could not do it in the 10 minutes that I spent on the issue.

As an alternate approach, one could simply backup the complete "good" database and then restore the backup to the target location. Unfortunately, I also tried this in the "technology preview" edition and could not get it to work. Again, that's not to say that it cannot be done-- I am just saying that I could not do it in the 10 minutes that I spent on the issue.

The other way is to simply physically move a copy of the "good" MDF file itself to the target location, as I note in the numbered steps to the solution that I used, above. Those steps were all necessary for me to get it to work.

That's all I have for now. Unfortunately, I cannot give you more details right now because I am in a location that is still on .NET 1.1; therefore, I cannot experiment with SQL Server 2005 Express. When I get to my home development location where I can try out SQL Server 2005 Express again, I may have forgotten this thread; so, I am giving you what I have now, FWIW.

HTH.

Thank you.

--Mark Kamoski

|||Many thanks, i'll give this a try :-)|||

Hi MDH,

Did you ever manage to get this working? I am trying to use SQL Server Express to copy tables from my local server to the remote server. I know it's easy in the full version because you have DTS, but it seems to be impossible in the Express edition.

Cheers.

No comments:

Post a Comment