In my application I need to have the user select one program (item) from the collection in a listbox. This listbox click event then triggers a sql query of an existing sql server data table using the selected program (item) in the sql 'where' clause. The returned data then will fill a datagridview on the same C# form as the listbox. The selection of the listbox item works. The query and filling of the datagridview does not. Suggestions please!

7 Years
Discussion Span
Last Post by history84084

This is in the dataset designer. Should it be in the click-event handler?

    private void InitCommandCollection() {
        this._commandCollection = new global::System.Data.SqlClient.SqlCommand[1];
        this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand();
        this._commandCollection[0].Connection = this.Connection;
        this._commandCollection[0].CommandText = "SELECT CAMPAIGN_ID, CREDIT_GRADE_PRE, SUB_GRADE, APR, ANNUAL_FEE, CREDIT_LINE, SE" +
            "GMENT, MAIL_CELL, MAILED, RESPONDED, APPROVED FROM dbo.[PROD_Mail Response] where campaign_id = cboxPickProgram.Text";
        this._commandCollection[0].CommandType = global::System.Data.CommandType.Text;

Edited by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.