I am attempting to configure the connection string in web.confg for an ASP.NET app to connect to Azure DB. I am new to this but am familiar with sql configuration strings to SQL Server. How do I configure the login and data source in the connection string I am building. I haven't ever dealt with the cloud like this. If my db name is DB1 how do I set the Azure path for the data source portion of the connection string. NOTE: I know where to configure it in web.config and know to create a connection object.
Thanks.
In the Azure portal, you can navigate to your database's dashboard and click 'Show connection strings' on the right side. See the first screenshot on the below tutorial:
http://azure.microsoft.com/en-us/documentation/articles/sql-database-dotnet-how-to-use/
To answer your original question, "Data Source" means the same as "Server", it is just your server name, i.e. blah.database.windows.net. All of the connection string keywords (including their synonyms) are documented here: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring%28v=vs.110%29.aspx
Related
as you know, the database connection parameters are listed in Web.Config which it's text, now the app is hosted in Windows, I want to apply follwoing:
1- exe file by clicking it should ask for the following
a -> database server host address
b -> database server sql user name
c -> database server sql database
d -> database server sql user password
after all the parameters are correct it should allow to store the connection and I will address the connection in webconfig(connection file) is for sure encrypted and it's show only encrypt the server detail(iis server) which even if some one copy the app folder to another server it should not work
--> here I know how to encrypt only in single file but the problem is for developing such exe which should check the detail connection if it's success and by server-IIS detail
where I should start, help of experts saves our time , best wishes
I went trough this answer but could not solve.
We store a template for building SQL Server CE connection strings in our web.config and use string.format to set the data source and temp path values.
In the web.config, the template for the DB connection string is:
"Data Source={0}; Temp Path={1}; Mode=Read Only"
In the web.release.config, we use to build deployment packages, the template for the DB connection string is:
Data Source={0}; Temp Path={1}
Now we only use the SQL Server CE database for read only operations. So, being a smartypants, I thought I would remove the connection string transform in the web.release.config and just always use the read only connection string from the web.config.
This worked fine for the database I was testing. But the same code running with a different SQL Server CE database fails with the following exception:
Exception 'System.Data.SqlServerCe.SqlCeException' with message 'The
database is opened with a read-only connection. Can't perform
post-initialization operations like re-building indexes and upgrading
public tracking. Please re-open with a read-write connection. [
Database name = D:\inetpub\wwwroot\MyApp\App_Data\Storage.sdf ]'
We are using the System.Data.SqlServerCe.4.0 provider
Why in my release build that is deployed to a server does read only access fail for some SQL Server CE databases but not others? It is the same code, just pointing at a different .SDF file. The .SDF files have the same schema, just different data.
Is the driver trying to rebuild indexes because the .SDF file is in some older format? Should we never use a readonly connection in production? Is that why the original code had the transform? why do they all work with a readonly connection on my Windows 7 workstation?
You should always specify a temp path, as moving databases between OS platforms/versions can require index rebuilds.
See my blog post post here: http://erikej.blogspot.dk/2009/08/running-sql-compact-from-cd-rom-read.html for more detailed info.
I have two conn strings in my web.config
The second of them connects to external database - the database is on different server than the current website.
Is it possible?
How do I write my connection string?
I have this now:
<add name="newConn" connectionString="server=www.somedomain.com;database=dbname;user id=dbuser;password=dbpass" providerName="MySql.Data.MySqlClient" />
But I'm getting error saying:
Access denied for user 'dbuser'#'currentdnsserver.com' (using password: YES)
Thanks
You have 2 questions:
Answers:
1. Absolutely.
2. You will need to write a connection string that use TCP/IP as the transport.
To debug this you should try connecting via the SQL Server Mgmt Studio using the credentials you are using in the conn string.
I assume you are using SQL Server, here is a typical connection string to a TCP/IP enabled DBMS using SQL Server authentication.
<add name="conn2" connectionString="Database=myDB;Server=serverNameOrIpAddress;uid=id;pwd=pwd;" providerName="System.Data.SqlClient"/>
The connection I wanted to establish was between different hosting server (one on Windows, another on Linux).
My hosting provider told me it's not possible to connecto from Windows .NET website to Linux MySQL db. Not sure why but not possible.
Would be possible on the same hosting they said.
Thank you for trying to help #T McKeown
Yes, you can connect to remote server and this is used alot.
The main thing that you should edit in your connection string is: Data Source.
Example:
Data Source=192.166.0.2;initial catalog=books;integrated security=False;user id=admin;password=!password1
Data Source: IP or URL of the computer you want to connect
Initial Catalog: Name of the Database you want to use
UserName and Password for the database user you want to use when you working with
the database are required.
I have developed my first website in ASP.NET with C#. It's a small website which uses Microsoft SQL server 2008 for database and I've deployed it on a free hosting site www.somee.com. It's database is working well on my computer but when I try to access the database on server it gives following 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)].
I have updated connection string of the database in web.config and I've used getConString() method for accessing connection string like this:
public string getConString()
{
return System.Configuration.ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
}
What can I do to solve this problem.
Wbsite url is: www.easyways.somee.com
Thanks all of you for your support. I got the solution for my problem. Actually I did something wrong either in creating a database or in using connection string.
Now I recreated a blank database and then I executed the SQL script that I created for my database by navigating to "User -> Managed products -> MS SQL -> Databases -> (Database name) -> New SQL query from file". And also updated the new connection string in web.config file.
This is the connection string I used now:
"workstation id=dataeasyways.mssql.somee.com;packet size=4096;user id=easyways_db;pwd=********;data source=dataeasyways.mssql.somee.com;persist security info=False;initial catalog=dataeasyways"
Your hosting provider provides the connection information for you (in the case of your hosting provider you can see their Help Page here, which shows you how to connect to their DB.
Basically it boils down to logging into their control panel.
In "User menu" navigate to "User -> Managed products -> MS SQL -> Databases -> (Database name)".
Also remember that since this is a remote database there is a small chance that its firwalled from the outside world and only local webservers can access the database.
Firstly, I know that there are a lot of similar topics, but none seem to solve my problem.
I have inherited a project where the front-end is built in ASP.NET and the CMS is built in classic ASP. I'm in the process of setting up a local development environment where I've copied the database from the live server and am configuring the website to connect to my new local DB.
The ASP.NET part is connecting with the connection string Data Source=.\\SQLEXPRESS; Database=DBNAME; Trusted_Connection=True; but I had to mess about with Application Pools and Permissions.
I'm having a problem with getting the classic ASP part of the website to connect to the SQL database. The error I am recieving is:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database "DBNAME" requested by the login. The login failed.
/cms/connections/Conn.asp, line 18
The code in that file is:
12. Dim Conn_STRING, URL, mailHost
13. Conn_STRING = "Driver={SQL Server}; Server=.\SQLEXPRESS; Database=DBNAME; Trusted_Connection=True;"
15. Dim conn
16. set conn = Server.CreateObject("ADODB.Connection")
17. conn.ConnectionString = Conn_STRING
18. conn.Open
I know it's a permission problem or some sort, but I can't get to the bottom of it. I'll appreciate any help at all :)
hmmmm, well, the asp.net part is using SQLExpress, connected via an attached file. DBNAME in the first example is going to refer to a db file name in the actual asp.net project. It's been quite a long time since I last used classic ASP, but I'd be STUNNED if it supports this. You need to attach the db file to an actual sql server and use it that way.
server=mycomputername\sqlexpress; database=DBNAME; user id=username; password=password
You'll need to open your database in sql express mngmt studio
http://www.microsoft.com/download/en/details.aspx?id=7593
Go into your security settings for that user and set the default database to "dbname" (whatver your real dbname is of course)
Ensure your app pool is set to run under the user that has permissions to that database. It may just be easier to enable mixed mode authentication and create a sql user to connect to the database rather than messing around with windows authentication on an app pool.
You wil lof course need to change your connection string then to support the sql authentication if you go that route.
http://msdn.microsoft.com/en-us/library/ms143705%28v=sql.90%29.aspx