I want to fill a GridView with data from a database and let the user choose what part of the "Cursussen" Table is shown. He can do this by changing the selection of the parameter in a dropdownbox.
Error : No overload for method "Add" takes 2 arguments.
protected void Page_Load(object sender, EventArgs e)
{
ConnectionStringSettings planner =
ConfigurationManager.ConnectionStrings["CursusDatabase"];
DbConnection connection = new SqlConnection(planner.ConnectionString);
DbCommand cmd = connection.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText =
"SELECT * FROM Cursussen " +
"WHERE CursusId = @CursusId";
cmd.Parameters.Add("CursusId", DropDownList1.SelectedValue); // <-- here
connection.Open();
DbDataReader rdr = cmd.ExecuteReader();
DataTable planning = new DataTable();
planning.Load(rdr);
connection.Close();
GridView1.DataSource = planning;
GridView1.DataBind();
}
}