I am attempting to connect to a database I created in SQL Server 2008 on my computer.
I have a Windows Authentication login which looks like this:
try
{
string sCon = @"Data Source=David-PC\SQLEXPRESS; Initial Catalog=ZarTrackDB; Integrated Security = true";
SqlConnection dbConn;
dbConn = new SqlConnection(sCon);
dbConn.Open();
}
catch (Exception ex)
{
MessageBox.Show(this, "An error occurd while attemtpting to connect to DB.\n" + ex.Message, "DB Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
however it keeps throwing an exception:
Login failed for user David-PC\David
I am able to connect to the Master DB though:
string sCon = @"Data Source=David-PC\SQLEXPRESS; Initial Catalog=Master; Integrated Security = true";
So i guess the probelm might be I do not have permissions? How do I go about giving myslef permissions to access this DB though when I login via SQL Server Management Studio I can insert create query etc on the ZarTrackDB perfectly.
I truly dont know what to do anymore please help!
EDIT:
here is a screen shot of my user mappings for the account I am trying to log in with:
User Mappings:

Server Roles:

UPDATE:
If I login to master and attempt to access ZarTrack :
string sCon = @"Data Source=David-PC\SQLEXPRESS; Initial Catalog=Master; Integrated Security = true";
SqlConnection dbConn;
dbConn = new SqlConnection(sCon);
dbConn.Open();
string sql = "USE ZarTrackDB "+
"CREATE TABLE Customers ("+
"CustomerID int IDENTITY PRIMARY KEY NOT NULL," +
"CompanyName varchar(30) NOT NULL,"+
"CompanyAddress varchar(40) NOT NULL,"+
"Email varchar(40) NOT NULL,"+
"PhoneNumber varchar(15) NOT NULL"+
");";
SqlCommand dbCmd = new SqlCommand();
dbCmd.CommandText = sql;
dbCmd.Connection = dbConn;
dbCmd.ExecuteNonQuery();
I get Exception:

It seems the
was the problem when I do:
It works perfectly