none
after placing an if statement query no longer returns results... what statement am i missing now? RRS feed

  • General discussion

  • I can't take any more drama.... I'm missing a statement to make the query return the resluts, prior to placing the if statement the query did return it.. HELP ME PULEASE!!!!

    protected System.Web.UI.WebControls.DataGrid RepeatGridSearchResults;

    public void DisplaySearchResults(string searchString)
    {
    SqlCommand cmd = new SqlCommand("Search", new SqlConnection(ConfigurationManager.ConnectionStrings["mine"].ConnectionString));
    cmd.CommandType = CommandType.StoredProcedure;

    try
    {
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@searchString", searchString);
    RepeatGrid.DataSource = cmd.ExecuteReader();
    RepeatGrid.DataBind();
    cmd.Connection.Close();
    cmd.Connection.Dispose();

    }


    catch (Exception ex)
    {
    lblNumberOfResults.Text = ex.Message;
    if (RepeatGrid.Rows.Count ==0) lblNumberOfResults.Text = "No matches found";
    }
    }
    • Moved by Jinchun ChenMicrosoft employee Wednesday, September 23, 2009 7:20 AM Move to appropriated forum. (From:SQL Server Reporting Services)
    • Moved by eryang Wednesday, September 23, 2009 8:13 AM (From:.NET Base Class Library)
    • Changed type Yichun_Feng Monday, September 28, 2009 1:18 AM Don't follow up
    Monday, September 21, 2009 1:43 PM

All replies

  • What kind of IF statement do youn refer to, the one inside of the catch sectoin? You need to be more specific. Do you receive an error now or just the blank data source? If you receive an exception, what is the error message text?
    Val Mazur (MVP) http://www.xporttools.net
    Wednesday, September 23, 2009 10:36 AM
    Moderator
  • You need to post the stored procedure.
    Paul ~~~~ Microsoft MVP (Visual Basic)
    Wednesday, September 23, 2009 1:21 PM
  • Hi FedUpWithSigningInAndChoosingNames,

    We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

    Best Regards

    Yichun Feng

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, September 28, 2009 1:17 AM