views:

1068

answers:

3

I've got a GoDaddy shared hosting account, and I need a database that is larger than the 200MB limit imposed on their included databases.

I'm looking for a way to create MDF and LDF files locally from a SQL Server 2005 Express server, and copy them into my webspace. However, I'm not having any luck making that work. GoDaddy won't help, and won't comment on how to accomplish this, or even if it's possible. I've never worked with connecting directly to MDF files either, which complicates things for me.

Does anyone have any experience accomplishing this with GoDaddy, or if not, then with another similar hosting environment? I'd appreciate any insight you could provide - specifically, what the connection string should look like, and any basic security I'd need to apply to my database prior to detaching it from my local server.

If I can't make this happen, then my only reasonable option left that I can think of is...{gasp}...Microsoft Access.

Thanks very much for the help.

A: 

What hosting package do you have? Can you provide a link to a page on the godaddy site that shows your hosting plan. I'm not sure what exactly the technical limitation you are trying to overcome is.

Also, have you tried uploading a backup of your database, and issuing a RESTORE command to it?

Justin Dearing
Justin: I'm using Windows Deluxe Shared Hosting:http://www.godaddy.com/Hosting/web-hosting.aspx?ci=9009The SQL Server databases that GoDaddy gives me have a limit of 200MB, which is not enough for what I'm trying to do. I have 150GB of space on my web space, so if I can't put my database on their database server, then I'll need to put it in my web server (in AppData or similar).Regarding backing up and restoring my database, it would just go into their SQL server, which limits me to 200MB, so I don't think that's a viable option.Thanks for the help.
Joe Enos
+1  A: 

You shouldn't have to create the MDF or LDF files from the SQL express server, they should already be created. It is just a matter of finding them on your computer. Mine would appear to be in a folder like this: C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data

There is a LOG folder as a sibling to the Data forlder as well. I have never done this with godaddy but it is not uncommon, it is how Visual Studio treates development of database aware web apps. There should be an App_Data folder that the MDF and LDF files would live. Then you would just have to change your config string to something like this:

<connectionStrings>
    <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>

Some of the settings in the config might be wrong for you case but I would check out these sources for more info.

http://weblogs.asp.net/owscott/archive/2005/08/26/Using-connection-strings-from-web.config-in-ASP.NET-v2.0.aspx

http://msdn.microsoft.com/en-us/library/bf7sd233.aspx

Good luck!

Kyle LeNeau
Kyle: Thanks for the comment - The web server doesn't have SQL Express installed, so .\SQLEXPRESS doesn't work. If I modify the connstring to connect to the DB Server, but still point to the file DB, it won't let me keep User Instance=true, since that's a function of Express, not full SQL Server. If I remove User Instance then I get:CREATE DATABASE permission denied in database 'master'.An attempt to attach an auto-named database for file D:\Hosting\_\html\_\App_Data\test1.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Joe Enos
+2  A: 

SQL Express runs as a shared service on the box. If you are looking for a file based database you should consider Microsoft SQL Compact, SQLite, or the new csharp-sqlite port.

You could create the files locally and copy them up to the server, but then you will have to attach your files into their SQL Instance and I'd guess that would be prohibited as the server might not have write permissions to your area.

Jon Masters
Jon: Thanks for the comment. I'm having a tough time getting SQL CE working also - it works fine locally, but when I upload it to the server, I get:PolicyException: Required permissions cannot be acquired.Could not load file or assembly System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 or one of its dependencies. Failed to grant minimum permission requests.Maybe this has something to do with the medium trust that GoDaddy uses - not really sure. Any ideas?I can try csharp-sqlite, but I was really hoping to stick with SQL Server.
Joe Enos
I don't have enough experience with SQL CE to give tech support. I considered both CE and SQLite and went with SQLite in the end. There are tools out there to convert a SQL Express database directly into SQLite and nHibernate has drivers that work with it as well.
Jon Masters
Thanks - I'll look into SQLite. At this point, I'm still in the beginning phases of this particular application, so the type of database really doesn't matter to me.I appreciate the help.
Joe Enos