How do I get a column from a table ?

Posts   
 
    
Zonkle
User
Posts: 18
Joined: 06-Mar-2005
# Posted on: 06-Mar-2005 17:41:42   

Hi,

Thank you for this program.

I have a few questions but I am going to ask them in Threads to help others to find it.

I am new to this program and trying to get used to it and decide to buy it or not simple_smile So my question now, how can I retrive a column from table ??

I think it using Filters, am not sure ,but I tried a lot and couldn't figure it out flushed

This :

    Dim brandname As New EntityClasses.BrandEntity
    Dim brands As New CollectionClasses.BrandCollection

    drpbrand.DataSource = 

    drpbrand.DataBind()

drpbrand is a drop down menu.

Thank you.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 06-Mar-2005 18:24:34   

Use a dynamic list for that. Please see the documentation: Using the generated code / Selfservicing / Using the typed view and typed list classes, SelfServicing -> Creating dynamic lists

With that you can define just 1 column and fetch that data into a datatable.

If you need a full written example for your case, please let me know simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Zonkle
User
Posts: 18
Joined: 06-Mar-2005
# Posted on: 06-Mar-2005 20:52:01   

Thank you very much.

I read the Dynamic list, but when I try to do like this code : ' VB.NET Dim fields As New ResultsetFields(3) fields.DefineField(EmployeeFieldIndex.FirstName, 0, "FirstNameManager", "Manager") fields.DefineField(EmployeeFieldIndex.LastName, 1, "LastNameManager", "Manager") fields.DefineField(EmployeeFieldIndex.LastName, 2, "AmountEmployees", "Employee", AggregateFunction.Count) Dim relations As IRelationCollection = New RelationCollection() relations.Add(EmployeeEntity.Relations.EmployeeEntityUsingEmployeeId, "Employee", "Manager", JoinHint.None)

Dim groupByClause As IGroupByCollection = New GroupByCollection() groupByClause.Add(fields(0)) groupByClause.Add(fields(1))

Dim dynamicList As New DataTable() Dim dao As New TypedListDAO() dao.GetMultiAsDataTable(fields, dynamicList, 0, Nothing, Nothing, relations, True, groupByClause, Nothing, 0, 0)

I can't define the "ResultsetFields" there is no such a thing confused And I also import :

Imports Commerce ' The generated project Imports SD.LLBLGen.Pro.ORMSupportClasses

I think the code that I should use to bind the column to the drop menu should look like:

. .

I didn't know what to do ... flushed since I didn't try the code. But what I want is just to take the data from the Column that is called "brandName" from the table "Brands" and put them in a Drop down menu called "drpbrand".

Thank you very much, and I hope that your tool will help me in my project. The problem that I have to do the project faster than what I'm doing and I have to learn about ur Tool, so if needed help you can help always?flushed ?

Thanks.

Zonkle
User
Posts: 18
Joined: 06-Mar-2005
# Posted on: 07-Mar-2005 11:28:22   

Hi,

Man this Tool is great simple_smile

I found out why the Resultsetfield didn't show up ...

Now can you please take a look at this code:


        Dim field As New HelperClasses.ResultsetFields(1)
        Dim brandlist As New DataTable
        Dim dao As New DaoClasses.TypedListDAO
        'Dim test As New DaoClasses.BrandDAO



        field.DefineField(BrandFieldIndex.BrandName, 0, "brandName")
        dao.GetMultiAsDataTable(field, brandlist, 0, Nothing, Nothing, Nothing, True, Nothing, Nothing, 0, 0)
        'test.GetMultiAsDataTable(field, brandlist, 0, Nothing, Nothing, Nothing, True, Nothing, Nothing, 0, 0)

        drpbrand.DataSource = brandlist
        drpbrand.DataBind()


After I run this code, the Drop down menu "drpbrand" shows something like "System.DataRow..." and that's set! What I am doing wrong ? I just want the field "brandName" which is in the table "Brands".

And did you see the "test" variable ? what is the difference between it and the variable "dao" ?

Thank you.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 07-Mar-2005 11:39:20   

Zonkle wrote:

Hi, Man this Tool is great simple_smile I found out why the Resultsetfield didn't show up ...

smile I guess an Imports did the trick wink

Now can you please take a look at this code:


        Dim field As New HelperClasses.ResultsetFields(1)
        Dim brandlist As New DataTable
        Dim dao As New DaoClasses.TypedListDAO
        'Dim test As New DaoClasses.BrandDAO

        field.DefineField(BrandFieldIndex.BrandName, 0, "brandName")
        dao.GetMultiAsDataTable(field, brandlist, 0, Nothing, Nothing, Nothing, True, Nothing, Nothing, 0, 0)
        'test.GetMultiAsDataTable(field, brandlist, 0, Nothing, Nothing, Nothing, True, Nothing, Nothing, 0, 0)

        drpbrand.DataSource = brandlist
        drpbrand.DataBind()

After I run this code, the Drop down menu "drpbrand" shows something like "System.DataRow..." and that's set! What I am doing wrong ? I just want the field "brandName" which is in the table "Brands".

You have to add this line before drpbrand.DataBind(): drpbrand.DisplayMember = "brandName"

And did you see the "test" variable ? what is the difference between it and the variable "dao" ? Thank you.

The entity dao's can't deal with multi-entity field list fetches as they're focussed on single entity fetches. The typed list is though, hence the usage of the TypedListDAO simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Zonkle
User
Posts: 18
Joined: 06-Mar-2005
# Posted on: 07-Mar-2005 13:04:47   

Otis wrote:

You have to add this line before drpbrand.DataBind(): drpbrand.DisplayMember = "brandName"

And did you see the "test" variable ? what is the difference between it and the variable "dao" ? Thank you.

The entity dao's can't deal with multi-entity field list fetches as they're focussed on single entity fetches. The typed list is though, hence the usage of the TypedListDAO simple_smile

Hi man,

There is no "DisplayMember" for the "drpbrand" confused I guess you meant the "DataMember", and I tried it and didn't work too rage

This is what I did :


        drpbrand.DataSource = brandlist
        drpbrand.DataMember = "brandName"
        drpbrand.DataBind()

Look how the results is :

I have two rows now in the "Brands" table , and I see that the code is returning two rows ... but not the actual data.

Thank you again.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 07-Mar-2005 13:28:24   

My mistake, I didn't look up hte class properties for an asp.net control.

WHen you see the type instead of the data, there is an exception somewhere. The properties you shouldn't set DataMember (as that's the name of teh table, and you just have one table), but you should set DataTextField and DataValueField, both to the same value.

Frans Bouma | Lead developer LLBLGen Pro
Zonkle
User
Posts: 18
Joined: 06-Mar-2005
# Posted on: 07-Mar-2005 16:36:34   

Thank you man it worked smile

I didn't what do you exactly mean ...... maybe you meant that because the DataTable is one table ? so I don't have to use teh DataMember ?

BTW, these two lines :


        drpbrand.DataTextField = "brandName"
        drpbrand.DataValueField = "brandName"

If i use one of them or both of them, the program works! hmm .. how is that ?

Thank you very much man..... and more questions will come for sure flushed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Mar-2005 10:07:36   

Zonkle wrote:

Thank you man it worked smile

I didn't what do you exactly mean ...... maybe you meant that because the DataTable is one table ? so I don't have to use teh DataMember ?

Exactly. If you check the documentation of the DropDownList for ASP.NET, you'll see that DataMember is used to tell the control to which datatable to bind when you bind a dataSET, but you bind already a datatable, so that's not important.

BTW, these two lines :


        drpbrand.DataTextField = "brandName"
        drpbrand.DataValueField = "brandName"

If i use one of them or both of them, the program works! hmm .. how is that ?

There is just one column, I think the control knows what to do... Databinding is often doing some weird voodoo magic... it's very inconsistent, almost every control has different quircks..

Frans Bouma | Lead developer LLBLGen Pro
Zonkle
User
Posts: 18
Joined: 06-Mar-2005
# Posted on: 08-Mar-2005 10:36:17   

Otis wrote:

Databinding is often doing some weird voodoo magic

smile Ok man I belive you.

Thanks.