Which connection string should I use with an application role in MS SQL? - sql-server

My client set up an application Role in Microsoft SQL Server 2008 for one database. He doesn't know how to change the connection string for that role and I have any idea about which connection string to use for this purpose.
Can anyone provide me an example of a connection string for an application role defined in MSSQL?

To not use AttachedFile in the connection you need to attach the mdf file to a SQL Server. Once attached you could use a connection similar to the one below but many examples can be found here
Data Source=myServerAddress;Initial Catalog=myDataBase; User Id=myUsername;Password=myPassword;

Related

SAS connection to SQL Server DB using Windows Authentication

Can anyone give me the libname statement for making SAS to SQL Server connection using windows authentication or is it even possible without entering userid and password?
Thanks
You will want to use a connection string that has Trusted_Connection=True; How that property is communicated to the engine is dependent on the engine.
A great resource for all things connection strings is https://www.connectionstrings.com/sql-server/

Create a public connection to SQL Server in Excel with Microsoft Query

I want to import data from SQL Server to Excel. Because I want to use parameters in the query's, I use a Microsoft Query instead of the standard SQL Server connection.
When making a custom connection the following screen comes up:
My problem is that the connection string this creates contains my name. Is it possible to create a public connection string that everyone can use? Or can that be done with this connection string aswell?
Below the connection string:
DRIVER=SQL Server Native Client 11.0;SERVER=[SERVERNAME];UID=[MY LOGIN];Trusted_Connection=Yes;APP=Microsoft Office 2010;WSID=[PC NAME];DATABASE=[DATABASE NAME];

Specifying login creditials for remote SQL connection string in ASP.Net/Entity Framework Core

I am following https://learn.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db to learn how to use the new .Net Core and Entity Framework Core and I am trying to create the connection string to a remote SQL Server. I updated the server and database strings but it does not show how to specify the username and password. I have done some digging but every entity framework core example I find is for localDB only. How am I to properly specify the login credentials and what should Trusted_Connection be set to for a remote SQL Server 2016 server?
The connection strings in EF Core remain the same as in EF6 and when you use pure ADO.NET.
For user/password authentication it's Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;.
For a list of common connection strings for SQL Server (and others), look at https://www.connectionstrings.com/sql-server/.
There is small difference in the connection string for the core.You can find it in the MSDN Blog.
we need to specify the server port number in the connection string.
Server = tcp:<ServerName>,<PortName>; Database = <DataBaseName>; User Id = <UserName>; Password = <Password>;
To get the server port number using the following query.
select distinct local_net_address, local_tcp_port from sys.dm_exec_connections where local_net_address is not null

How can I connect to a remote IIS database on the same network?

I'm creating a test server to add functionality for a webpage. The original server hosts a webpage that is connected to a database. In order to test on our test server, I need to connect to the database on the original server. How can I do this using the connection strings?
I'm sorry if this doesn't make sense. I'm new to this.
Here are a few common connection string formats that you could use. Additional formats and database providers can be found on www.connectionstrings.com
SQL Server Standard Security
Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;
myServerAddress
The name of the original server.
myDataBase
The name of the database that you are attempting to connect to on that server. If you go to the original server and look at how it connects to the database, it should provide this information.
myUsername and myPassword are self explanatory and these should also be found on the original server. This is assuming the original server was using a SQL account. If it was not, then use the below line of code.
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

SQL Server - Database 'Database' does not exist. Make sure that the name is entered correctly

I'm trying to generate my database tables from my Entity Framework model, but I'm getting this error when I execute the generation query:
Database 'Database' does not exist. Make sure that the name is entered correctly.
I'm able to connect to the local server just fine.
My connection string, which was generated by VS when I selected 'Database.mdf':
metadata=res://*/Models.Models.csdl|res://*/Models.Models.ssdl|res://*/Models.Models.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
The database definitely exists, but I've noticed that the only databases it's picking up on the server are called master, model, msdb and tempdb.
Can anyone help?
Edit: I've just realised that the SQL connection dialog that comes up when you click "Execute SQL" allows you to connect to a server. But my DB isn't on a server, it's just a user instance database. But that's the only option, so how would I execute against my database? I have the database open in the 'Server Explorer'.
The connection string is referring to a user instance database is that what you intended? I got the impression possibly not from the question.
If not try changing it to Data Source=ServerName\InstanceName;Initial Catalog=Database;Integrated Security=True;
If you are using a user instance database, specify the full path to the location of the database with USE directive.
For example:
USE [C:\Project\Database.mdf]
GO
When connecting the server, you need to select another data source, then enter the name of the local server on which the database is located.
I can't speak for Entity Framework, but within SQL, "database" is a (very) reserved word. Try calling your database (and it's files) something else, even if just "MyDatabase".
I faced such problem when running a script in SQL Server Management Studio to do some stuff on my Local SQL Server. I noticed that the Query Window that I was running the script in was connected to a Remote SQL Server not my local machine.

Resources