I'm on an AWS Windows 2016 server. It comes pre-installed with SQL Server 2016.
I have a .NET 4.8 website where I'm trying to connect the website (on the web server) to the SQL Server instance (also installed on the web server).
I have a simple C# function to tell me if my connection string works (everything I've tried returns false).
public static bool IsServerConnected(string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
try
{
connection.Open();
return true;
}
catch (SqlException)
{
return false;
}
}
}
private static string connect = ConfigurationManager.ConnectionStrings["db"].ConnectionString;
public static string connDb
{
get { return connect; }
set { connect = value; }
}
// Usage:
bool TestConnection = IsServerConnected(connDb);
This is from my web.config
file (connection string)
[I'm only including the **** in the string for privacy reasons, I used the actual SQL Server Name]:
<connectionStrings>
<add name="db"
connectionString="Data Source=EC2AMAZ-84****;Initial Catalog=testdb;Integrated Security=True;Trusted_Connection=Yes;"
providerName="System.Data.SqlClient" />
</connectionStrings>
This is the screen from SQL Server Management Studio (that I'm accessing from the same Windows Server that the website is on):
Can anyone help me out? How should I setup my connection string?
EDIT
From some of the help I received below, this is where I am currently at:
- I ran the script to create the new Login and Role
- After the command completed successfully, I exited SSMS and then restarted SSMS using the Services (see image 2)
- I logged into SSMS using the credentials: 'MyUser' and 'P@ssword01'
- I received an error stating the login was successful but Shared Memory Provider error (SQL Server error 223)