I'm trying a DataSet
to a GridView
. I have guided myself with some internet examples
This is part code behind and when executing it shows me the following error:
Fill: The SelectCommand.Connection property has not been initialized.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) {
refresh();
}
}
public void refresh()
{
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["cadenaConexionAlumnos"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("select * from carrera");
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet dsCarrera = new DataSet();
sda.Fill(dsCarrera);
GVCarrera.DataSource = dsCarrera;
GVCarrera.DataBind();
}