These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: CreateMultiQuery() and binding results to combobox
PostPosted: Thu Jun 21, 2007 11:23 am 
Newbie

Joined: Thu Jun 21, 2007 11:05 am
Posts: 1
Location: Poland / Lublin
Hi,
I've got a problem.

I have a combobox named cb_Klient, which I want to bind a results to.
I use IMultiQuery interface and CreateMultiQuery() method. Here's its code:
Code:
IMultiQuery zbior = _session.CreateMultiQuery()
                .Add(_session.CreateQuery("SELECT k.Id_klienta FROM klient as k"))
                .Add(_session.CreateQuery("SELECT o.Id_oferty FROM oferta as o"))
                .Add(_session.CreateQuery("SELECT a.Id_agenta FROM agent as a"));


Everything's fine, but want I want to do are properties of combobox:
- this.cb_Klient.DisplayMember
- this.cb_Klient.ValueMember

How to do, that results from queries like:
Code:
IMultiQuery zbior = _session.CreateMultiQuery()
                .Add(_session.CreateQuery("SELECT k.Id_klienta, k.Nazwisko FROM klient as k"))
                .Add(_session.CreateQuery("SELECT o.Id_oferty, o.Opis_oferty FROM oferta as o"))
                .Add(_session.CreateQuery("SELECT a.Id_agenta, a.Nazwisko FROM agent as a"));

were binded to combobox's mentioned properties properly ??

I can also add, that when I execute it, in the combobox I've got a returned (ie. 5 rows) of the same string "Array of object[]". Sth like that.

Any ideas?

Best wishes,
Greg


Top
 Profile  
 
 Post subject: Re: CreateMultiQuery() and binding results to combobox
PostPosted: Fri Jun 22, 2007 8:34 am 
Regular
Regular

Joined: Fri Feb 18, 2005 3:34 am
Posts: 88
Location: Poland/Wrocław
grzgar wrote:
I can also add, that when I execute it, in the combobox I've got a returned (ie. 5 rows) of the same string "Array of object[]". Sth like that.


Try to introduce an adapter class that gets a row and has a ToString() method. And then bind the combo to adapret instances instead of direct binding to the result set.

Possibly you could even create these adapters directly in the queries if the adapter class has an appropriate constructor:

Code:
SELECT new AdapterClass(k.Id_klienta, k.Nazwisko) FROM klient as k


However I've never tested such approach - just remember the construction from the docs...

_________________
Please rate this post if you've found it helpfull
Roland


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.