有人可以帮我解决这个问题。我一直在努力解决这个错误几个小时,似乎无法解决这个问题。任何帮助将非常感激!
<connectionStrings>
<add name="DB01Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.EntityClient;provider connection string="data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\DB01.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<connectionStrings/>
代码:
protected void Page_Load(object sender, EventArgs e)
{
string CS = ConfigurationManager.ConnectionStrings["DB01Entities"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("Select Course_ID, Course_Institution, Course_Name, Course_Description, Course_CutOffPoints, Course_English, Course_Mathematics, Course_Science from tblCourse", con);
con.Open();
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "Course_Name";
DropDownList1.DataValueField = "Course_ID";
DropDownList1.DataBind();
}
}
}
}
错误消息的图片。 Error Message
再一次,非常感谢您的帮助!