c# - already an open DataReader associated with this Command - when I'm not using datareader? -
I am getting an error that an open dataarder is associated with this command when I am not using a datesterer (Though probably the executereader is the same thing) If I do not have a stockman, then how do I close it? Using
(SqlConnection conn = new SqlConnection (ConnectionString)) {SqlCommand cmd = new SqlCommand ("spSelectAllTypes", Connecticut); Cmd.CommandType = CommandType.StoredProcedure; SqlCommand cmd1 = New SqlCommand ("spSelect AllTripA", conn); Cmd1.CommandType = CommandType.StoredProcedure; Conn.Open (); // checkbox list cbTransportType.DataSource = cmd.ExecuteReader (); CbTransportType.DataBind (); // dropdown list ddlTripTypeA.DataSource = cmd1.ExecuteReader (); DdlTripTypeA.DataTextField = "TripType"; DdlTripTypeA.DataValueField = "TripTypeID"; DdlTripTypeA.DataBind (); }
I just want to be able to have a bunch of dropdown list in an open connection database. (Before each open and closed for each control)
Execute Reader
Return an open data reader You should really settle that before the connection is closed, although I'm not sure how it will look in relation to using it as a data source.
Comments
Post a Comment