I am trying to establish a connection to a Microsoft Sql Server express edition databse called PrimeMinisters and get the following error.
Cannot open database "PrimeMinisters" requested by the login. The login failed. Login failed for user 'DESKTOP\Arian'.
I am asuming I need a user name and password but as this is just for home use I dont see the need for a username and password in the connection string.
I added the database as a new connection in database explorer and this is the connection string I added to the eventhandler.(desktop is the name of my pc)
try
{
string connect = @"Data Source=DESKTOP\SQLEXPRESS; Initial Catalog=PrimeMinisters; Trusted_Connection=Yes;";
SqlConnection sqlConn = new SqlConnection(connect);
sqlConn.Open();
LabMessage.Text = "A connection has been established";
}
catch (Exception ex)
{
LabMessage.Text = ex.Message.ToString();
}
How can I overcome this error message and establish a connection with the database?
Kind regards