SQL Server Performance

System.Data.DataRowView' does not contain a property with the name ListID

Discussion in 'SQL Server 2005 General Developer Questions' started by talish, Oct 22, 2008.

  1. talish New Member

    Hi to all ... Please Help me ...[:(]
    A strange problem occurred sometimes cause the following error. What is interesting is the Select query contain the field (LicenseID) and bind successfully all the time. Only in sometime this error happened . I have no idea what was the real cause of this problem. After retrieving the data from sql server the resultant dataset was stored in a dataset and then stored in a dataview. This dataview then assign to a session variable. I already check session before binding and if session was goes out of scope i rediriect to the login page and rebind the grid .
    And also check any one was alter the dataset externaly may cause this error. But this scenario also not happend. I need a solution to this strange bug.
    Any one please help me to point out any reason for this error . Below I put the query to retrieve the dataset.

    Public Sub GetCustomers()
    Dim fldSearchBy As String
    fldSearchBy = FilterWhere()
    'Dim cmdFill As New OleDb.OleDbCommand
    Dim cmdFill As New SqlClient.SqlCommand
    Dim sql As String

    FilterWhere = ddlSearchBy.SelectedItem.Text

    sql = "SELECT [customers].[customerName], [customers].[firstname], [customers].[phone], customers.[listid]," & _
    "[customers].[lastname],cast(supportstartdate as smalldatetime) supportstartdate," & _
    " [customers].[QuickBooks], [customers].[UserLicenses],[customers].[phone],cast (supportEndDate as smalldatetime) supportEndDate ," & _
    " [customers].[TelephonyTrial],[customers].[Telephony],[customers].[TrialEndDt],[Customers].[LicenseID], " & _
    "(SELECT Count(codelog.codeid) AS CountOfcodeid " & _
    "FROM codelog " & _
    "WHERE customers.[listid] = codelog.[listid] " & _
    "and codetype = 'General (System)' " & _
    "GROUP BY codelog.ListId) as licensesUsed," & _
    "(SELECT Count(codelog.[codeid]) AS CountOfcodeid " & _
    "FROM codelog " & _
    "WHERE customers.listid = codelog.listid " & _
    "and codetype = 'QuickBooks Interface' " & _
    "GROUP BY codelog.ListId) as [qblicenses],[username],[password],LOWER([LicenseType]) as LicenseType " & _
    "from customers "

    sql += " where 1=1 "
    sql += FilterWhere
    sql += " order by customers.customername"

    Dim dsCustomer As DataSet = New DataSet
    'Dim daCustomer As New OleDb.OleDbDataAdapter(sql, getConnectionString)
    Dim daCustomer As New SqlClient.SqlDataAdapter(sql, getConnectionString)

    Dim dv As New DataView

    If Not dsCustomer Is Nothing AndAlso dsCustomer.Tables.Count > 0 AndAlso dsCustomer.Tables(0).Rows.Count > 0 Then
    dv = dsCustomer.Tables(0).DefaultView
    'dvCustomers is Property procedure for setting dataview in to session variable(see below)
    dvCustomers = dv
    dvCustomers = Nothing
    End If
    Catch ex As Exception
    End Try
    End Sub
    Property Procedure
    Public Property dvCustomers() As DataView
    _dvCustomers = Nothing
    If Not IsNothing(Session("dvCustomers")) Then
    _dvCustomers = CType(Session("dvCustomers"), DataView)
    End If
    Return _dvCustomers
    End Get
    Set(ByVal Value As DataView)
    Session("dvCustomers") = Value
    End Set
    End Property
    Bind Grid
    Public Sub BindGrid()
    If Not IsNothing(dvCustomers) AndAlso dvCustomers.Count > 0 Then

    dgCustomer.DataSource = dvCustomers

    dgCustomer.CurrentPageIndex = Nothing
    dgCustomer.DataSource = Nothing
    Utilities.ShowMessage(lblEmptyMessage, trMessage, "No record found in searching, try again.... ", Constants.MessageType.Message)
    End If
    End Sub
    First this error is raised ----- System.Data.DataRowView' does not contain a property with the name ListID(Primary Key)
    then the following error raised in the subsequence operation ...
    ServerError in '/KeyedAccess'Application.

    DataBinding:'System.Data.DataRowView' does not contain a property with the name'LicenseID'.
    Description: Anunhandled exception occurred during the execution of thecurrent web request. Please review the stack trace for more informationaboutthe error and where it originated in the code.

    ExceptionDetails: System.Web.HttpException:DataBinding: 'System.Data.DataRowView' does not contain a property withthename 'LicenseID'.


    Line103: <HeaderStyle Width="250px"></HeaderStyle>
    Line104: <ItemTemplate>
    Line105: <asp:Label id=lblLicenseKey runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "LicenseID") %>'>
    Line106: </asp:Label>
    Line107: </ItemTemplate>

    SourceFile: E:websitesidb-sys.comwebkeyedaccessCustomerListing.aspx Line: 105


    [HttpException(0x80004005): DataBinding: 'System.Data.DataRowView' does not contain aproperty with the name 'LicenseID'.]
    System.Web.UI.DataBinder.GetPropertyValue(Object container, StringpropName) +197
    System.Web.UI.DataBinder.Eval(Object container, String[]expressionParts) +79
    System.Web.UI.DataBinder.Eval(Object container, String expression) +108
    ASP.customerlisting_aspx.__DataBinding__control25(Object sender,EventArgs e) inE:websitesidb-sys.comwebkeyedaccessCustomerListing.aspx:105
    System.Web.UI.Control.OnDataBinding(EventArgs e) +99
    System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +206
    System.Web.UI.Control.DataBind() +12
    System.Web.UI.Control.DataBindChildren() +216
    System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
    System.Web.UI.Control.DataBind() +12
    System.Web.UI.Control.DataBindChildren() +216
    System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
    System.Web.UI.Control.DataBind() +12
    System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex, Int32dataSourceIndex, ListItemType itemType, Boolean dataBind, ObjectdataItem, DataGridColumn[] columns, TableRowCollection rows,PagedDataSource pagedDataSource) +200
    System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(BooleanuseDataSource) +1519
    System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +56
    System.Web.UI.WebControls.BaseDataList.DataBind() +72
    key.CustomerListing.BindGrid() +168
    key.CustomerListing.btnSearch_Click(Object sender, EventArgs e) +65
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
    System.Web.UI.WebControls.Button.RaisePostBackEvent(StringeventArgument) +107
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(StringeventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandlersourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    System.Web.UI.Page.ProcessRequestMain(BooleanincludeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)+5102

    VersionInformation: Microsoft.NET Framework Version:2.0.50727.832; ASP.NETVersion:2.0.50727.832
  2. satya Moderator

    Welcome to the forums.I believe the error is caused due to the fact that the returned resultset is not compatible with the number of columns you are presenting in the application, so it brings up the questions suchas do you always load all of the data from the database/sp into a DataTable?

Share This Page