I am developing an ASP.NET website. I wanted to shift whole of my work to another PC of mine. I copied the website to the other PC>Open>Create ASP.NET folder>App_Data
and pasted the database.mdf and database.ldf files there. I was getting some exception when I was trying to run the website as it showed the "could not open the connection from con.open()". Is there some other step too that I am missing?
Sql Server database files are not like any simple html files that can be copied between machines. You need to make sure that the database that is getting served up: e.g. there is a Sql Server instance running that can present the database to your web application.
Here's an article on how to attach an mdf file to a Sql Server.
You need to attach the mdf and ldf files to the sql server instance on the target machine. You may need to adjust your connection string as well, unless you used a local name reference like "." for the data source.
What is your connection string? Chances are the path in the connection string has the local path to the database file on your original development machine.
Related
I have deployed my project on the server and also exported the database on the server.
Now I would like to skip the installation. How is it possible?
I tried to put the 'Settings.txt' file in App_Data and also the 'InstalledPlugins.txt', but it didn't help.
'Settings.txt' needs to be updated with new SQL Database in your PROD server. Just copying over will not help. If you just copy over, then NopCommerce from PROD will look for Database in your local or dev PC which is not accessible (in most cases)
'Settings.txt' stores db connection as ADO.Net connection string. so you can edit easily.
I've created a website in Visual Studio 2012, now when I upload my files to the web server I receive an error whereby the system cannot find the file specified.
It seems to only happen on files which fetch data from a database.
I've tested my connection string and that seems to be working as I've close the connection as well as deleted the local db I was using. My site works fine when run locally, but the second I try access it online I get the same error.
Link to error image:- http://imgur.com/wkXV8fe
I've highlighted the error that puzzles me in the image. It keeps trying to find the file on my local pc it seems. I've searched through my code and can't seem to find anything that is hard coded.
Your help is much appreciated, hopefully someone has encountered and solved this problem.
The possible reason are,
The folder which containing specified file is may be read only or admin access or hidden in server machine. If possible, check the folder properties.
Make sure the file containing folder has uploaded or not on server.
It won't find your local pc if you hosted on other IP(server). The same root folder may be present on server side, so don't get confuse with server and local machine.
The "file not found" error is actually misleading, the error you need to deal with is the SqlException error and indicates the connection string is wrong - you need to update the connection string to access the SQL Server externally.
Are you also deploying the database to another server or are you attempting to access the same database as when testing locally? If you are accessing the same database locally, make sure the web server you are using to host the website can actually access the SQL Server on your local machine - check all firewalls and other things, and make sure that the SQL Server accepts TCP connections.
my asp.net application runs successfully in development server of visual studio. but when i deploy my application in IIS it generates the error as follows
Failed to generate a user instance of SQL Server due to failure in
retrieving the user's local application data path. Please make sure
the user has a local user profile on the computer. The connection will
be closed.
what are the necessary changes that i should do in my application. also guide me how to deploy my database on IIS.
What is your connection string?
More specifically, I am wondering if you are using a .mdf file as your database.
If this is the case, you need to ensure that your web application has write-permissions within the App_Data folder of your website.
It is hard to say exactly without seeing your connection string, but possibly this KB article will help. It relates to SQLExpress and the error you are seeing.
http://support.microsoft.com/kb/2002980
I uploaded my site to a server and i cant use my database on it.
I cant take or use any information on it.
Im using Access Database with C# on web developer asp.net .
this is the code of the connection string:
return string.Format(#"Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}", DAL.path);
DAL.Path is the path of the database file on the server.
Taking a guess here, but if the server you are uploading to is a 64bit Windows platform, then the standard Jet library is not available. I believe there is an equivalent package, but this would need to be installed to make use of it.
I built a prototype I'm looking to deploy. It uses a database file MySite.mdf that I created. At some point in the process, the database file ASPNETDB.mdf was added to the project.
When I look at the web.config file, I see the connectionStrings tag but in there I only see the nested tag for MySite.
Now that I'm looking to deploy, what do I put for the second file in the tag.
Thanks.
You are using a SQL Server Express User Instance; if the server you are deploying to support this, then you won't need to change your connection string when you deploy.
The most common problem deploying a user instance database is that the server doesn't support user instances. (Note that user instances are only supported by SQL Server Express Edition). If the server doesn't support this configuration, you'll have to create a database on the server and change your connection string, a process that could involve quite a few steps.
If, on the other hand, your server supports users instances and it's using the same SQL Instance name that you are, e.g. SQLEXPRESS, the default instance name, you should be able to simply deploy your site and it will run (as long as you include the ASPNETDB.mdf file in the deployment).