in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Data don't dsiplay after using the XPServerCollectionSource

Last post 11/17/2008 9:31 PM by Craig Michael. 1 replies.
Page 1 of 1 (2 items)
Sort Posts:
Previous Next
  • 11/17/2008 7:37 PM

    Data don't dsiplay after using the XPServerCollectionSource

    Below is my code that uses XPServerCollectionSource , I don't know what I am missing because the data doesn't display in the xtragrid.

    code in my form:

    Dim con As New SqlConnection
    Dim conString As String = "Data Source=(local)\SQLEXPRESS;Initial Catalog=vSampleDB;Integrated Security=True"

    con.ConnectionString = conString
    Dim table As New DataTable

    Using con
    Dim cmd As New SqlCommand("Select top 1 * from StudentTable" , con)
    Dim reader As SqlDataReader = cmd.ExecuteReader(CommandBehavior.KeyInfo)New DataTable("StudentTable" )
    Dim dict As New ReflectionDictionary
    Dim classInfo As XPClassInfo = New XPDataObjectClassInfo(dict.GetClassInfo(GetType(LiteDataObject)), "Dataset" )
    Dim col As DataColumn

    For Each col In table.Columns
    If col.Unique Then
    classInfo.CreateMember(col.ColumnName, col.DataType, New KeyAttribute())
    Else
    classInfo.CreateMember(col.ColumnName, col.DataType)
    End If
    Next

    XpoDefault.DataLayer = XpoDefault.GetDataLayer(MSSqlConnectionProvider.GetConnectionString("(local)\SQLEXPRESS", vSampleDB"), dict, AutoCreateOption.SchemaAlreadyExists)

    Dim xpSource As XPServerCollectionSource

    xpSource = New XPServerCollectionSource(New Session(), classInfo)
    xpSource.DisplayableProperties = "IdNo;LastName;FirstName;MiddleName;Gender"
    xpSource.ObjectClassInfo = classInfo
    gridSearch.ServerMode = True
    gridSearch.DataSource = xpSource

    End Using

     

    my class code:

    Imports DevExpress.Xpo
    Imports DevExpress.Xpo.Metadata


    <NonPersistent(), OptimisticLocking(False)> _
    Public Class LiteDataObject : Inherits XPBaseObject

    Public Sub New(ByVal session As Session, ByVal ci As XPClassInfo)
     MyBase.New()
    End Sub

    End Class

     

  • 11/17/2008 9:31 PM In reply to

    Re: Data don't dsiplay after using the XPServerCollectionSource

     Oops, I got it! after few minutes of debugging. I just replace the name dataset into tablename

    from:

    Dim classInfo As XPClassInfo = New XPDataObjectClassInfo(dict.GetClassInfo(GetType(LiteDataObject)), "Dataset" )

    to:

    Dim classInfo As XPClassInfo = New XPDataObjectClassInfo(dict.GetClassInfo(GetType(LiteDataObject)), "StudentTable" )

    This is solved!

Page 1 of 1 (2 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED