SQL server won't open DB created by Visual Studio - asp.net

I've built an ASP.Net site in Visual Studio, and created the DB inside it (the .mdf file is in the APP_data folder).
Now, when I want to deploy in the customer site, I think about maintaining the DB without open Visual Studio, and by using the SQL Server Express tools (back up etc.).
I've searched how to do this, and learned that I should attach the .mdf file to sql server.
I've tried to do this and failed!
The error is: Unable to open the physical file "< .mdf >". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)
Google didn't helped me to solve the problem.
Now I have 2 options:
1. To give up and deploy the site in the current situation where the DB is an .mdf file and ASP.Net can connect to it by the SQL server express compact (in the proccess).
To extract all the data (I need to think how...) and import it to new DB, this time in SQL Server DB.
Wat would you recommend doing?
Thank you in advance.

If on Windows Vista or higher, try opening SQL Server Management Studio by right clicking and saying "Run as Administrator". As Mitch mentioned maybe it is just a permissions issue. Then try attaching to the database.

Error 5 is usually permissions related. Do you have permissions to access the file in it's location?

If you've created it in Visual Studio, it's most likely an Express database. SQL Server does not support "user mode" database connections which SQL Server Express use. Despite sharing a name, they are two fairly distinctive and different technologies.
To view the contents of an SQL Express database (ie- created in Visual Studio) I just use the Visual Studio server explorer.

Related

Could not load file or assembly microsoft.sqlserver.management.sdk.sfc

Receiving below error message in Visual Studio 2008 while creating a connection for database.
could not load file or assembly
'microsoft.sqlserver.management.sdk.sfc ,Version=10.0.0.0,
Culture=neutral,PublicKeyToken=89845dcd8080cc91' or one of its dependencies.
The system cannot find the file specified.
I am trying to create database internally i.e. .mdf file and store it in the App_data folder.
But I'm not able to create the connection.
Please help me to sort out the issue quickly.
You can download these files from Microsoft website.
1.Microsoft SQL Server System CLR Types
2.Microsoft SQL Server 2008 Management Objects
3.Microsoft SQL Server 2008 Native Client.
After installing the above three files try to connect your application with sql server database and if still you got the same error message then don't worry and close your application then start it again and you will be able to connect it.

Establishing connection to SQL Server Error

I opened my web project today and for some reason I could not gain access to my database files. I get the following exception whenever I try to add, edit or refresh my database:
A network related instance specific error occurred while establishing
a connection to SQL Server. The Server was not found or is was not
accessible. Verify that the instance name is correct and that SQL
Server is configured to allow remote connections.
I took a look at my connection string for any spelling errors and deleted my database and replaced it in the folder I had it in. I can't seem to find a fix for this so any help would be a appreciated. I am using Visual studio 2008 for this web project.
This sounds like the same problem that I had myself awhile back. My problem was that my SQL service pack 1 did not install properly so I had to install Microsoft SQL Server System CLR Types, Microsoft SQL Server 2008 Management Objects and Microsoft SQL Server 2008 Native Client. After that I could create new SQLdatasources but I could not edit the ones I had previously before my problem. I had to restart my computer in safe mode and delete my SQLEXPRESS folder then recreate the database connection in visual studios. When I finished that everything worked fine.
This is the site I got those downloads, http://blogs.cametoofar.com/post/cannot-load-file-or-assembly-microsoftsqlservermanagementsdksfc.aspx

deploying asp.net site on IIS

Okay. Here's my problem.
I have this source code of VB.net + asp.net application which was developed on another computer. It comes with,
database - Microsoft sql .mdf + ita log file
source code of the web application
Now what I want to know is,
Do I need to install Microsoft SQL server to deploy this on IIS?
(I do have Microsoft SQL server management studio express installed on my PC but the thing is I can't connect to database engine of it after installing WAMP.)
Do I have to copy application's database somewhere else to deploy the site?
What are the changes do I have to make in the code to run it properly?
any help would be appreciated!
1) In order for the server to know what the database file (assuming the file is related to microsoft sql) you will need to install microsoft sql on the server.
2) The database should be fine wherever on the server as long as you know where it is.
3) This is a hard question to answer... be more specific?

SQL server express backend for ASP.NET web service

I come from a linux/apache/php/mysql background. For my current project, I am forced to write web services using ASP.NET. I have installed visual studio and created an ASP.NET web service project. The web service I'm creating will use a SQL database backend. I see that visual studio installed "SQL Server Express 2008." I can see that there is a service called "SQL Server (SQLEXPRESS)" that is running. My question is, how do I run queries against this database? Where's the front end? What tool do I use to create databases and tables? Is there something else I have to install?
I feel completely lost and my google-fu fails me. There are so many different SQL products from microsoft that I can't tell what is the easiest path to just having a simple database with tables I can query from my development machine. With MySQL, I would install the MySQL database, download MySQL query browser and start firing queries at it. How can I do that with Visual Studio/SQL Server Express?
You can download SQL Server Management Studio from here. This is the GUI for working with SQL Server. It will let you create databases, tables, stored procedures, etc. as well as writing queries and manually edit data in the tables.
Aside from SQL Server Management Studio, you can use the Server Explorer tab in Visual Studio (by default on the right side, next to Solution Explorer) to add a data connection. You can do most of the most common database tasks (create/query tables, create views, etc) from there.
there's a command line tool that installs with SQL Server (all versions) called SQLCMD.exe, should be in your install path.
Visual Studio also lets you create dbs, run queries, look at table structures and data (including creating and deleting them, etc), you do that by opening your Server explorer window and making a connection to your local instance (.\SQLExpress by default).
Finally, as the other person mentioned, SQL Server Management Studio Express is a free download, and well worth the time it takes to install.

Publishing a SQLExpress Database from Visual Studio

I have tables in a local database I've built in Visual Studio 2008 that I want to publish to an existing database on the server that I will be deploying my Asp.NET app. Unfortunately the only two options I have for deploying this database when I select "publish" is -script to file- and -publish to shared hosting provider-. My dedicated DB server is neither.
Can someone help point me in the right direction?
Put your database in the App_Data folder (this is a common approach with SQL Express) and then when you publish there should be an option for including files in the App_Data folder. Once your site goes live, you would definitely NOT want to select this option :)
Also, here is a Microsoft article about using SQL Express with ASP.NET: http://msdn.microsoft.com/en-us/library/ms247257.aspx

Resources