I have ASP.NET project and attached mdf database.I want to deploy it to remote server.I have just ftp account.The project works well on my local but ı had problem while deploying.I changed my connection string like. Please help me what is the problem ?
<add name="libraryConnectionString"
connectionString=" Server =.\SQLExpress;
AttachDbFilename= myusername#ftp.myserver.com/App_Data/LIBRARY.mdf;
Integrated Security=SSPI;
User Instance=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
You have to create a Ms-Sql server database (remote) along with user via control panel or you may ask to your hosting provider to create a database and user. Once database is created then you may execute your script (You may use Visual Studio Database Publishing wizard) and construct a new connection string for your web-app.
Have a look at MSDN article - Deploying a Database by Using the Database Publishing Wizard
The Database Publishing Wizard in Visual Studio enables you to deploy
a SQL Server database (both schema and data) to a hosting environment.
You can run the wizard by right-clicking a database in Server Explorer
and then clicking Publish to provider.
Related
I've successfully deployed my ASP.NET project to Azure but the database has been deployed with no data, consequently throwing internal server errors due to functionality requiring that data. I can't see the exact error message as I'm unable to disable customErrors on my project (there's no webconfig file on Razor Pages)
I need to update my database on Azure with the data currently stored locally. How do you do this and is this possible?
N.B - I am using EF core with code-first migrations for data access
On the local machine open the "Microsoft server SQL management studio", connect to the local database server and navigate to the appropriate database. Rightclick on the database name and select "Generate scripts...". Select the tables you want to export, then click "next>". On this screen click the "Advanced" button, scroll down to "Types of data to script" and select "Data only". Now you can generate the script and copy that to a connection to the Azure DB, that can be an other query in de Management Studio or in the Azure portal.
I'm having problems connecting to an MSSQL database in an ASP.NET Web Forms application. The error I get the is the user corp\earth3 can't connect. earth3 is the name of the computer ... the logged in user is corp\earth (a domain administrator) which is what works when connecting to the database using MSSQL Management Studio. I'm building the web app on Windows 10 and its being deployed for production use on a Windows 2012 server (which has the same connection problem as the win10 machine).
I've tried each of the following in web.config. This works while connecting to other database instances on the db server, but not on this one.
<add key="sqlConnectString" value="Data Source=db01\pd; Initial Catalog=PDB; Trusted_Connection=Yes;"/>
<add key="sqlConnectString" value="Data Source=db01\pd; Initial Catalog=PDB; Integrated Security=SSPI;"/>
What am I doing wrong here? Why can't I connect to the db using corp\earth?
Thanks.
Modify the Identity in the application pool with a user that can connect to the database. Create a custom app pool if you don't want to make a change that would affect other web sites it uses.
I created a new Empty website in Visual studio Express 2013.
I created an ASP.NET folder: App_Data.
Then I went to SQL Server Management Studio. I created a new Database in which I provided the path to the App_Data of the website that I created.
I named the database "FacebookData"
Then I went to Visual studio; I found the database in the App_Data folder and also in Server Explorer.
I went to Web.config, And under I added
<connectionStrings>
<add name="DataConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\FacebookData.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
I click Build -> Rebuild Solution
When I close SQL Server Management Studio, and reopen it again.
The Database named "FacebookData" is missed from the SQL Server Management Studio Databases list!!!.
I still find it in the Visual Studio in App_Data folder and Server Express.
If I close and open the SQL Server Management Studio before adding the to the Web.config. The Database is still exist in the SQL Server Management Studio. which makes me feel that there is something wrong in the connection string.
Any clues?
Your connection string says that database should be "attached" to SQL server when application is run. To have it permanently living in SQl server you should just use SQL server management studio to attach it manually, that way it stays attached. You also need to change you connection string to
"Server=your_sql_server_instance;Database=FacebookData;Integrated Security=True"
As I have been following a MusicStore tutorial, new MVC3 project created a following connection string for me:
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
My model tables got created in .\SQLEXPRESS and all the users/roles tables are stored in the aspnetdb.mdf in the App_Data folder.
I would like to have the model tables and user/roles tables on my .\SQLSERVER or localhost rather then scattered between .\SQLEXPRESS and the mdf file. I'm struggling with the right connection string. Can anyone suggest the right one please?
Everyone who does this has to make sure that name of the connection string should be the name of the context class derived from the *DbContext*
It sounds like you need to run aspnet_regsql on your ApplicationServices database. You can find it in C:\Windows\Microsoft.Net\Framework\4.xxx\aspnet_regsql.exe.
A default project uses ApplicationServices db as default for membership, roles, and profile. The sproc dbo.aspnet_CheckSchemaVersion is a sproc in the ASP.NET SQL Membership Provider schema.
Response to comment #1
Do you have a database instance running on your machine named SQLSERVER? The exception you mentioned is a common one, if asp.net cannot find the database using your connection string.
Response to comment #2
That makes sense. Integrated Security=true tells the connection to use the process running the MVC app (usually IIS app pool) for the sql server login. If you are testing from Visual Studio / Web Developer Express / etc, the web server is likely running on a process with your windows account. So if you can windows auth against the db server, MVC should also be able to.
User Instances are meant for SQLEXPRESS.
I have uploaded my database backup and it works fine. but since I've created a new user from ASP.NET Configuration I've that it saves the user information in the ASPNETDB.
I already published my database from MVS and open it in M SQL Server Management Studio 2008 to create the backup but I haven't find the ASPNETDB in it.
my question is:
doesn't this database just upload it automatically when I upload my database? coz when I publish my website it doesn't appear.
if not, How can I upload ASPNETDB so I can login to my site because I'm using authorization to this user ?
Ok im gonna make a few assumptions here and explain them because this could be many things:
Assumption 1 (connection string issue). the user credentials for a database running on your local sql server are likely to be valid on the server on which you deploy to (seems to be the way of the world) try connecting to the remote database using the credentials in the remote "published" copy of the websites configuration file. (connection string)
Assumption 2 (publish settings not correct). when you use the "publish" option from within visual studio you only deploy the website to my knowledge but some say you can configure it to deploy the database as well.
I would suggest making a change (eg add a table to the aspnet database) on your dev machine then using publish to see if that new table appears on the remote server, if it doesn't go to the server explorer in visual studio and run the wizard by right clicking on your database and clicking on "publish to provider" i tend to push the entire db to a script file then manually run that on the remote database (seems the cleanest option).
Assumption 3 (does the database even exist on the server). I could be wrong here but from what you're saying it sounds like you published the application and not the database to the server ... that results in some nice yellow server errors.
Check that the database exists if not ... do as suggested in asumption 2 and push the database manually.
I suppose you're using the Membership API.
If you are using ASP.NET on a machine with SQL Server Express Edition, the required by Membership API underlying data store is created automatically for you when you create the first user. This functionality is provided through the SqlMembershipProvider. The SqlMembershipProvider automatically creates a new database in the website’s App_Data special directory called ASPNETDB.MDB. This database implements the complete schema, which is necessary for storing and managing user information, role information, user-role assignments etc.
You can easily check it. In your web.config you should see something like:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
So this database should have been uploaded along with your web site.
Please consider this tutorial if you want to create aspnetdb or necessary tables in your own database (which is a good praxis).
May be you will be also interested in the similar discussion here. Besides if you still want to get this .mdf database in SQL Server Management Studio you can learn how to attach a database here.