Wednesday, March 21, 2012

Help configuring database to work as intended

Hello everyone, I have created my web application in VS 2005 using asp.net 2.0 and the built in sql .mdf database creater that comes with visual studio. After I developed my website, I then wanted to move it to one of our servers on the network, which I did without a problem. The website works fine but here is my challange. I need users to be able to connect to the database via login script and the script inserts computer data into the database. So I figured I need to attach the Database to SQL Server 2005. When I try to do this it gives me this database is in use. So I stop the website in IIS, and it allows me to add the database into the SQL Server. Once I do this, and start the website again, the website no longer works and I get a bunch of database errors, that do not get fixed untill I re-copy the website to the server.

Is there a way to just connect to a .mdf file on the network that is not attached to a sql server, through a connection string in a login script? Maybe there is something else I need to do to the database before copying to the server? Or should I re-programm the website with a newly created database in SQL Server, and use that as the datasource?

There is no need to stop the webserver to copy or attach the database. to attach the database bring the particular database to offline and copy the mdf and ldf as per u r required location.

Thank u

Baba

Please remember to click "Mark as Answer" on this post if it helped you.

|||

Ok but then why, when I attach the database to a SQL Server, and try to run the website again, it no longer works? It gives me a bunch of database errors that basiaclly come down to, the database is already open.

|||

Hi,

using asp.net 2.0 and the built in sql .mdf datab

From your description, it seems that you want to move the mdf file in SQLExpress to SQLServer2005, right?

If so, I suggest that you can use aspnet_regsql tool to achieve that. The ASP.NET SQL Server Registration tool is used to create a Microsoft SQL Server database for use by the SQL Server providers in ASP.NET, or to add or remove options from an existing database. The Aspnet_regsql.exe file is located in the [drive:]\%windir%\Microsoft.NET\Framework\version folder on your Web server.

You can give the option '-d' to specify the name of the database to create or modify for use with application services. If the database is not specified, the default database name of "aspnetdb" is used.

For details, see:http://msdn2.microsoft.com/en-us/library/ms229862(VS.80).aspx

Thanks.

sql

No comments:

Post a Comment