locked
Trouble using multiple SelectCommands RRS feed

  • Question

  • User-485061880 posted

    Hi all,

    I have been trying to use multiple SelectCommands in a single AccessDataSource as the data source settings are the same, only the SelectCommand is different. But I have been receiving this error everytime I try to run the select command. Can anyone explain to me what this error means?

    DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'MatricID'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'MatricID'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'MatricID'.]
       System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +8657061
       System.Web.UI.WebControls.DetailsView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +1262
       System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
       System.Web.UI.WebControls.DetailsView.PerformDataBinding(IEnumerable data) +12
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
       System.Web.UI.WebControls.DetailsView.DataBind() +4
       System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
       System.Web.UI.WebControls.DetailsView.EnsureDataBound() +184
       System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +22
       System.Web.UI.WebControls.DetailsView.OnPreRender(EventArgs e) +17
       System.Web.UI.Control.PreRenderRecursiveInternal() +80
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
    

    Below is the code used to change the SelectCommand:

    protected void runCmd(object src, EventArgs e)
    {
        string[] cmd = new string[2];
        cmd[0] =
    "SELECT * FROM [StudentList] WHERE ([MatricID] = @matric)";
        cmd[1] =
    "SELECT [EventName], [TixIssued] FROM [TixIssued] WHERE ([MatricID] = @matric)";

        if(matric.Text.Length == 9)
        {
            mug.ImageUrl =
    "~/pic/" + matric.Text + ".jpg";
           
    for(int i =0; i<cmd.Length; i++)
            {
                data.SelectCommand = cmd[i];
            }
        }
       
    else
        {
            mug.ImageUrl =
    "~/pic/Blank.jpg";
            msgBox(
    "No such student record!", "No Records Found");
        }

    Additional Info: I am using C#.

    Do I need to run the Select() method? If yes, what should I put for the arguement? Thanks in advance.

    Thursday, May 21, 2009 11:37 PM

Answers

  • User-821857111 posted

    I suggest you look at getting this in one query using a JOIN: http://www.mikesdotnetting.com/Article.aspx?ArticleID=72.  The article shows how to do this with Sql Server Epxress Studio, but the Access Query Designer is almost identical.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 22, 2009 11:57 AM
  • User-485061880 posted
    hi mike! i've solved the problem by changing the select command to

    "SELECT StudentList.*, TixIssued.EventName, TixIssued.TixIssued FROM (StudentList INNER JOIN TixIssued ON StudentList.MatriculationID = TixIssued.MatricID) WHERE (StudentList.MatriculationID = ?)"

    then from the detailsview and gridview, i just chooses the data i want to be shown! thanks for your help anyway

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 23, 2009 12:35 AM

All replies

  • User-821857111 posted

    I suggest you look at getting this in one query using a JOIN: http://www.mikesdotnetting.com/Article.aspx?ArticleID=72.  The article shows how to do this with Sql Server Epxress Studio, but the Access Query Designer is almost identical.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 22, 2009 11:57 AM
  • User-485061880 posted
    hi mike! i've solved the problem by changing the select command to

    "SELECT StudentList.*, TixIssued.EventName, TixIssued.TixIssued FROM (StudentList INNER JOIN TixIssued ON StudentList.MatriculationID = TixIssued.MatricID) WHERE (StudentList.MatriculationID = ?)"

    then from the detailsview and gridview, i just chooses the data i want to be shown! thanks for your help anyway

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 23, 2009 12:35 AM