Ok, so I know there are other SO posts on this subject, but none of them are helping me on this. My code is throwing an exception saying:
Invalid Object Name 'Player'...
The Player table is included. I can see it in the Server Explorer. Where am I going wrong here? Thanks!
string connectString = @"Data Source=(LocalDB)\v11.0;
AttachDbFilename=C:\Users\Lisa\Desktop\CIS 365\BaseballDB\Baseball.mdf;
Integrated Security=True;Connect Timeout=30";
using (SqlConnection con = new SqlConnection(connectString))
{
string selectQuery = @"SELECT * FROM PLAYER";
using (SqlCommand com = new SqlCommand(selectQuery, con))
{
con.Open();
SqlDataReader reader = com.ExecuteReader();
if(reader.HasRows)
{
while(reader.Read())
{
Console.WriteLine("{0}\t{1}", reader.GetInt32(0), reader.GetString(1));
}
}
else
Console.WriteLine("No Rows Found.");
reader.Close();
}
}