sql server connection string - sql-server-2005

I just deployed my database to my remote server. I am trying to create a connectionstring to the remote server and it won't work. I am using godaddy. I kept having this message: could not establish a connection to the database. Here is the connectionstring for the local server:
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
Can someone help me with the connection for the remote server? Lets say my database name is collins and my password is database, and the remote hosting server=quiz.db.4423045.hostedresource.com;

Given those connection elements you mention, your connection string ought to look something like this:
<add name="RemoteConnectionString"
connectionString="server=quiz.db.4423045.hostedresource.com;database=collins;
user id=?????;password=database;"
providerName="System.Data.SqlClient" />
What you're missing is a user name for the connection to the database (or you didn't specify one) - you need to place that into the connection string as value for the user id= attribute.
For a great listing and explanations of all things about connection strings, you should definitely check out http://www.connectionstrings.com

First I would check that you can access ports TCP 1433 and UDP 1434 on that server (you need also the UDP port since you are using the SQLEXPRESS instance in the server).
You can check that using nmap/ZenMap (Download) or any other port scanner. The ports should be reported as open.

Related

SQL Server (Linked Server)

My database is from a linked server and I have a problem with my connection string in ASP.NET (web.config) it says that :
Database schema could not be retrieved for this connection. Please make sure the connection settings are correct and that the database is online. Cannot open database "AA" requested by the login. The login failed. Login failed for user 'sa' at DataObjectSupport(423,6)
I try to use this connection string.
<connectionStrings>
<add name="localconnection" connectionString="Data Source=SERVERNAME;Persist Security Info=True;Initial Catalog=database; uid=sa; Password=password; " providerName="System.Data.SqlClient"/>
</connectionStrings>

How to access a server system's local db from another system?(case:server-client scenario)

we used this connection string in client system where "Data Source=.*.**.57" is of server ip address and made the changes in the sql server configuration manager in server system accordingly.(i.e: TCP/IP protocol enabled)
<connectionStrings>
<add name="ConString"
connectionString="Data Source=**<ip address>,1433\SQLEXPRESS;Initial Catalog=HYD_TM;User ID=**;Password=**;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
Its always easier to debug connection string problems from an interface that is interactive such as Excel or sql management studio. In excel you can try to import a table from the data tab. If you succeed you can inspect the connection string and use it in your app.

Failed login for user

I'm developing a website for sharepoint using asp.net, it is connected to a database. In visual studio server explorer, the database is accessible using a new sql user I created. I granted sysadmin permissions to that user. However, when I deploy the site and run it, it gives me this error 'login failed for user'.
The sql server is configured to allow mixed authentications. I restarted the server, I played with the user permissions but nothing ever changed.
The connection string I got it from server explorer which I'm sure it is correct:
Data Source=servertest;Initial Catalog=qDB;User ID=me2;Password=***********"
What should I do? I've tried every possible solution I found on google and I ended up here.
Try like this by editing your connection string:-
Server=myServerAddress;Database=myDataBase;User Id=myUsername; Password=myPassword;
I too had same scenario this worked for me
<connectionStrings>
<add name="connectionstring" connectionString="Data Source=XYZ\SHAREPOINT;Initial Catalog=DBName;Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
You can Use connection string like this
<appSettings>
<add key="KhadamatConnectionString"
value="Server=[copy name from Your ServerName of SSMS];Database=AcaService;uid=admin;pwd=mypass;" />
</appSettings>
or
<connectionStrings>
<add name="KhadamatConnectionString" connectionString="Data Source=[copy name from Your ServerName of SSMS];Initial Catalog=AcaService;User ID=admin;Password=mypass;" providerName="System.Data.SqlClient"/>
</connectionStrings>

Can't connect to database when database has user and password

I am developing mvc 4 projects and when I use the following connection string it works:
<add name="name"
connectionString="Server=.\sqlexpress;Database=dbname;
Trusted_Connection=true;"
providerName="System.Data.SqlClient"/>
But when I add a username and password to this project, I can't connect to my database. I added the user credentials correctly. I have db_owner permission for this database, and in my database everything is correct. The connection string below does not work:
<add name="DocContext"
connectionString="Server=.\sqlexpress;Database=DocContext;
User ID=pooria;Password=19216801;Trusted_Connection=false;"
providerName="System.Data.SqlClient"/>
Connection String You are using follows format -
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
User ID=myDomain\myUsername;Password=myPassword;
Try using IP Address, Port in Data Source field like -
<connectionStrings>
<add name="ConnectionStringName"
providerName="System.Data.SqlClient"
connectionString="Data Source=190.190.200.100,1433;
Initial Catalog=MyDatabaseName;
Integrated Security=False;
User ID=MyUserID;Password=MyPassword;
MultipleActiveResultSets=True" />
</connectionStrings>
And the following link may help you
LINK

provider: SQL Network Interfaces, error: 25 - Connection string is not valid

I developed this application on my local computer using VS2012 and SQL 2008R2. I am trying to move it onto production server. It is a virtual server with 2012 SQL Server. I checked all the properties for remote connection and everything is enabled. The application opens with the login screen and once I enter the username and password (this was created on my computer using WSAT. Now I 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: 25 - Connection string is not valid)
This is what I have in web.config:
<connectionStrings>
<remove name="LocalSqlServer" />
<add connectionString="Server=\\events;Database=Digital Signage;Integrated Security=true" name="DSConnectionString" />
<add connectionString="data source=\\events;Integrated Security=SSPI;AttachDBFilename=c:\\DS\aspnetdb.mdf;User Instance=true" name="LocalSqlServer" providerName="System.Data.SqlClient" />
Not entirely sure, but some points which may help you troubleshoot:
You can use a resource like this to help you generate the appropriate connection string
I am not sure that Server=\\events sounds entirely right - you should perhaps replace this with the actual SQL instance name here when deploying remotely (either <machine name> or <machine name>\<instance name> for a named instance)
You probably don't need to explicitly state the port which SQL Server is listening on (if it's still the default 1433), but something to keep in mind
Do you have anywhere that you explicitly reference the connection string LocalSqlServer in your code? If so, have you changed that to reference the connection string DSConnectionString before building and deploying? (NB. It may be better to just keep the connection string entry but change the value of the connection string to what you need for the SQL 2012 instance, rather than creating a new connection string entry but I'm not sure about your specific use case)