I have uploaded my website to my webhost and it works great except the form authorication. When i try to login at get this error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
When i deploy the website i publish it from Visual Studio to a local folder and then upload it to the webhost via a FTP client program. The problem here is that the App_Data folder is empty when i publish the website to my local folder. Could this be the problem?
Check if your server allows to run user instances. If it allows then you need not do anything and just upload the MDF file to the App_Data folder on the server and you're good to go. You can also include App_data for publish which will automatically pick-up the App_Data folder along with the content.
If your server does not allow user instances then you need to perform following steps..
Ask admin to give you a SQLServer database along with access credentials.
From your Visual Studio right click on your database from the server explorer and select the option to PUBLISH TO PROVIDER. Follow the wizard steps and generate the SQL script with or without default data.
alt text http://ruchitsurati.net/myfiles/db.png
Connect to your Remote SQL Server from management studio and run the generated SQL script on the database given by your admin.
Update the connection string in your application for deployment.
Tick the "include files from the App_data folder" checkbox when publish.
alt text http://img260.imageshack.us/img260/8891/appdatapublish.png
Related
I've created an ASP.NET website which runs perfectly from Visual Studio. It connects to a SQL Server .mdf database file in the App_Data folder. I published the project using FTP. The live website cannot however connect to the database, as it is LocalDB, and my host uses a SQL Server (SqlException (0x80131904))
I uploaded an identical copy of the local .mdf database file from my computer to the host's SQL Server. I then tried to form a data connection with the server database from Visual Studio, however my host doesn't allow remote database access, for security reasons, resulting in error 40.
I'm using ASP.NET MVC in my application so I need access to the database to create models. My host has said "you can access SQL Server databases using ASP scripts running on your presence".
So my question is: how do I create models based on my host's SQL Server database when remote access isn't allowed?
When you're testing with Visual Studio, you should connect to the local copy of your database. When you're ready to publish your application, copy the database to the remote sql server and attach it. The copy of your application which is published should then connect to the uploaded database on that server.
That way you have one environment for testing and one for real use. There shouldn't be any need for Visual Studio to connect to the remote database.
P.S. To allow you to connect to different databases in different environments, usually you set your database connection string in the web.config file. So if you create different config transforms for each build configuration (e.g. debug and release) then visual studio will create the correct version of the config file when you do a Publish operation. See https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/web-config-transformations for info about configuration transforms.
I am able to access a .mdf file on local IIS. However, when I move it to the server under app_data, I can't. Am I missing a step?
Additional Information
The .mdf is under app_data on the server.
It appears like it is trying to connect, but cannot.
Connection string is as follows:
Public Const SQL_PRO As String = "Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\MyDB.mdf;Integrated Security=True"
Update 2
Here is the Error Message. Sql Express 2008 is installed on IIS
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
Thanks,
Eric
In your VS Project, in solution explorer, choose the MDF and choose properties (Alt+Enter), for Copy to Output Directory, choose Copy Always. Im thinking your file isn't packaged when publishing.
I’ve created a .NET website that uses SQL Server 2008 R2 with a linked server to an Access database (.mdb). The linked server works, I can browse to the .mdb tables and query the tables in SQL Server. When the website is run using Visual Studio, all tables are accessed without a problem. When the website is run using IIS, I get an error when it tries to select records from the Access database. The SQL server tables are fine. The error is “Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "[Name of linked server]". (Which is also the name of the database.)
Here are the details in no particular order:
Windows Server 2008 Enterprise 64-bit
SQL Server 2008 R2 64 – bit
IIS7
The access database has an "Access 2000 File Format" (seen when
the file is opened in Access 2010)
Office is not installed on the server (including Access)
IIS is set up with Anonymous Authentication using the IUSR account.
The IUSR account has been given full control over the directory where
the .mdb database resides.
Views are created from the Access tables and the website accesses the
Views
This is the connection string:
add name="ApplicationServices"
connectionString="data source=[server];
Integrated Security=SSPI;
Initial Catalog=[SQL server db];"
providerName="System.Data.SqlClient"
In SQL Server, this is the code that was used to set up the Linked Server
EXEC sp_addlinkedserver
#server = N'LinkedServer',
#provider = N'Microsoft.ACE.OLEDB.12.0',
#srvproduct = N'OLE DB Provider for ACE',
#datasrc = N'C:\RTS_NEW\RTS\App_Data\Data\AccessDatase.mdb';
GO
Under Linked Servers -> Providers, the Microsoft.ACE.OLEDB.12.0 provider has had the following items enabled under Properties
Dynamic Parameter
Allow inprocess
Disallow adhoc access
This is interesting. When I run the website through Visual Studio and it hits the SQL Server database (without hitting the Access database), an .ldb file is created in the same directory as the .mdb file. When I browse to the same page in IIS, a .lbl is not created. No ldb file is created either when I go to a page that accesses the Access database. Could IIS be putting the file in a different directory that does not have permissions set for IUSR? Where would I find that directory?
I’ve restarted SQL Server (MSSQLSERVER) with no effect.
Can anyone see what I’m overlooking? Or give me an idea of where to look next? Any help is appreciated!
Solution
Using ProcMon, I was able to tell which directories needed permissions set.
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
I found adding the AppPool account to the "Group or user name" of a folder in order to give it permission a bit tricky. Here's a good explantion:
IIS7 Permissions Overview - ApplicationPoolIdentity
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.
I am trying to deploy my .NET webservice on to provider (somee.com). I published the webservice and copied the folder over to the hosting site. I have my App_data folder copied too. I can access the service webpage. But when trying to access the website I received the following error. I have sqlserver express on my local machine.
A network-related or
instance-specific error occurred while
establishing a connection to SQL
Server. The server was not found or
was not accessible. Verify that the
instance name is correct and that SQL
Server is configured to allow remote
connections. (provider: SQL Network
Interfaces, error: 26 - Error Locating
Server/Instance Specified)
should i make i changes to my web.config file.
Please help
You have to modify your ASP app to use the database provided by somee for you (see http://somee.com/MSSqlDefault.aspx), not the one in app_data. You also need to upload your deployment scripts and configure the somee provided database before you can start running your ASP app.