Monday, March 26, 2012

Moving a database to a server

I have a SQL Server 2005 Express database on my local machince called OpenAssess.mdf. The server we host with has a file extension of .mdb. How can I go about getting my database to the server? I tried changing the extension to mdb on the local machine but then it tried opening the database in MS Access and didn't work. I just need to connect to the database in my web pages. Here is my connection string and then the error which is visible at the botton of openassessment.org.

*********************************************connection string*************************************************

OPEN_Conn = "Provider=SQLOLEDB;Data Source=connectionToHostServer;Network Library=DBMSSOCN;Initial Catalog=OpenAssess.mdb;User ID=myuserid;Password=mypassword"

*****************************************************error*********************************************************

Microsoft OLE DB Provider for SQL Servererror '80004005'

Cannot open database requested in login 'OpenAssess.mdb'. Login fails.

Hi,

Which edition of SQLServer does your host support?

If SqlExpress, just upload your mdf file onto the app_data folder on your server and make the connection string look like:

"data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"

Generally, the host will give you the instance name and you may assign the data source attribute with that.

If SqlServer, you will need to have the .mdf database files attach to server manually since other editons of SQLServer does not support attaching database files automatically at runtime. Also,you will need to modify your connection string and make it look like:

"data source=ServerName\InstanceName;Initial Catelog=DatabaseName;User ID=myuserid;Password=mypassword"

Thanks.

sql

No comments:

Post a Comment