I have made my database in SQLExpress and its a master database . I would like to create a CD for my project so need the database file. I am not able to find that file please suggest a solution
thanks!
Your database files would be in the App_Data folder by default if you are using SQL-Express provided with Visual Studio.
You can generate an SQL script of your database which can be used to re-create it in different db server by running the script again. For this right-click on the database in the Server Explorer and select Publish to Provider.
You'll need the .mdf and .ldf in the SQL Server installation directory, but if you've created everything in the master database, I'd recommend creating a different database and moving everything there instead. The master db shouldn't be used for stuff like that.
Related
I'm quite new to ASP.NET and I encountered a problem when publishing my project to Azure. After configuring the connectionStrings in Web.config, I have successfully uploaded my local database structure to Azure. However, all tables on Azure are now empty, without any local data. So how can I upload both the database structure as well as the data in it? Thanks in advance.
To migrate an existing SQL Server database to Azure SQL Database you can export the schema as a TSQL script and then execute that script against Microsoft Azure SQL Database as follows:
1.Open SQL Server Management Studio and connect to an instance of the Database Engine.
In Object Explorer, right click a database to open a menu, select Tasks…, and then select Generate Scripts.
2.Choose objects to export.
3.Set scripting options. You have the options to save the script to file, clipboard, new query window; or publish it to a web service.
4.Set advanced scripting options.
You can also set the Types of data to script to one of the following based on your requirements: Schema only, Data only, Schema and data.
5.After the script is created, you have the option to modify the script before running the script against an Azure SQL Database to transfer the database.
You can now run this script on your Azure SQL Database.
For more details, you could refer to this article.
You have to create a post deployment script. If the tables are created just fine on your azure application, then you must define what default data they will have. So in your post deployment script you will insert the data you want.
ASP.Net 4.0/C#/MSSQL/Microsoft SQL Server Management Studio
Hey I am now at the stage where I want to move a project to a live server
Now I want to move the tables from the ASPNETDB file in the App_Data folder
to the server.
I have used the Aspnet_regsql.exe tool to successfully generate the following tables
on my shared hosted server
dbo.aspnet_Applications
dbo.aspnet_Membership
dbo.aspnet_Paths
dbo.aspnet_PersonalizationAllUsers
dbo.aspnet_PersonalizationPerUser
dbo.aspnet_Profile
dbo.aspnet_Roles
dbo.aspnet_SchemaVersions
dbo.aspnet_Users
dbo.aspnet_UsersInRoles
dbo.aspnet_WebEvent_Events
Now what is the next step to essentially copy the tables from ASPNETDB.MDF
to these tables on the server?
Many thanks =)
What version of SQL server have you got?
If you can open the database locally in SQL Management Studio you can just use Generate Scripts that you can then simply open and run on your production server. It has the option to copy
Data
Schema
Both
So you can start with an empty database on Production and copy both the data and schema at once with a single .sql file and you'll be good to go.
You can use the export data feature from the management studio to migrate the data from the msf file to the live dtabse.
You are really better off putting all the membership etc. tables, views and stored procs into the main database for your production application. You can do this with the Database Publishing Wizard, which will create a script to recreate everything including all the data. No need to use two separate databases.
Alternatively, one can run this exe to copy empty tables from ASPNETDB.mdf to external SQL server.
drive:\WINDOWS\Microsoft.NET\Framework\versionNumber\aspnet_regsql.exe
I am trying to export my database on sql server 2008 as a SQL server primary data file so that I can drag and drop it within my ASP.NET application APP_Data Folder, rather than refering the web app to the database datasource in sql server 2008. This might generate a problem in accessing the database when the web app is hosted. Is there a way to export it as .mdf file with its logs, drag and drop it to my web app ?
Regards.
M. Shbib, I think what Mr. Lewis means is "have you tried detaching the database in SQL Server, then copying the .mdf and .ldf files from the SQL Server Data folder to your App_Data folder?"
You can find where your files are by right-clicking your database in SQL Server and selecting Properties. The path is listed in the File section, but you may have to scroll right to find it. It should be something like c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLSERVEREXPRESS\MSSQL\DATA (depending on your version of SQL Server). You will need to detach the database in SQL Server before you are allowed to copy it, otherwise you'll get an error that it is in use. Once you've detached it, navigate to the Data folder, copy both the mdf and ldf files and paste them into your App_Data folder.
Have you tried detaching the database on the SQL server, then copying the file to your App_Data folder?
I am trying to deploy my web application created with asp.net in visual studio 2010. I have successfully created .exe and .msi file, install it and run using IIS Manager. However, it needs a database which is why it is returning
System.Data.SqlClient.SqlException: The SELECT permission was denied on the object 'TableName', database 'master', schema 'dbo'.
whenerver I try to run it on browser with localhost.
How do I include my database file in deployment so that when I install my application in another computer, the database will also be created?
It is not at all clear what exactly you mean by database file but if you are referring to an SQLLite or SQL Server CE database file all you have to do is go to properties and change the "Copy to Output Directory" property to "Copy if Newer" (don't forget to do the same with the required class libraries).
If you are referring to SQL Server, Oracle or some other RDBMS database than you can't just copy the file, you'd have to either use DDL to create the database or attach the database file using the SSMS.
EDIT: I did not pay attention to the exception you posted so the second part of my question is relevant. SQL Server database file cannot be just copied to another computer, the target computer must have the SQL Server installed and you must detach the file from your local SQL Server and attach it on the remote SQL Server using the SQL Server Management Studio.
Hi I am trying out the membership features for .NET and I am using the ASP.NET Web application Administration Tool. My question is where is the user data being stored? I checked my databases and I cannot find it anywhere. I also tried to look for any information within Providers in the admin tool but I still could not locate a path. Can someone help me out? Thanks.
[EDIT]
Nothing is in the App_Data folder.
Also I was wondering when I right click App_Data and try to add a database, there is no option to do so. (Add New Item).
Look for a file called ASPNETDB.MDF in the App_Data folder of your web application project. That's a SQL Express database file.
Edit: Try looking in the App_Data folder in Windows Explorer. It may be on the disk but not showing up in the project inside of Visual Studio.
https://web.archive.org/web/20210513220018/http://aspnet.4guysfromrolla.com/articles/120705-1.aspx
I think, it would create a database by name aspnet by default.
Check it :)
It's saved in a database file under your ASP.NET application's App_Data folder.
You can configure it by aspnet_regsql.exe tool to include in your sql server instance :
aspnet_regsql.exe -E -S localhost -A mr
Check your web.config for the connection string to the database. If it's sql server then there will be a bunch of tables prefixed with 'aspnet_' or something very similar.
If you need to create the tables and stored procedures for the membership/roles provider you can open a Visual Studio command prompt (check your Start menu) and run aspnet_regsql. The .exe is also under the %WINDOWSDIR%\Microsoft.NET\Framework\v2.0.50727\ directory.
It'll enable you to select a database from a running of Server and create everything you need to be getting on with.