Reputation: 181
I'm using ado.net to display date from an sql database. Here is the below code:
protected void Page_Load(object sender, EventArgs e)
{
string cs = ConfigurationManager.ConnectionStrings["YoutubeConnectionString1"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("Select CityId, CityName, Country from Youtube", con);
con.Open();
drpCountries.DataSource = cmd.ExecuteReader();
drpCountries.DataTextField = "CityName";
drpCountries.DataValueField = "CityId";
drpCountries.DataBind();
}
}
}
Every time I run this I get an error saying "Invalid object name Youtube".
Thanks
Dan
Upvotes: 0
Views: 40
Reputation: 555
Select CityId, CityName, Country from Youtube <-- this is the table where you are getting CityId, CityName and Country from. What is this table called? It's not YouTube.
Upvotes: 1