BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Odd behaviour when using QueryDataSet and JdbTable

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder DB Swing
View previous topic :: View next topic  
Author Message
sdf
Guest





PostPosted: Fri Oct 22, 2004 3:49 pm    Post subject: Odd behaviour when using QueryDataSet and JdbTable Reply with quote



The following is my code to create a QueryDataSet and add it to a
JDBTable. I am requesting a query that has more than 1 row and 1 column
however the JdbTable functions tell me there is only 1 row and 1 column.
I have included some print statments from my program in the "Output"
section. How do I get the right values from JdbTable?


Thanks,

Anthony

JPanel grid_panel = new JPanel(new BorderLayout());
String sql = "select name, exp_id, type, remark, expression from
_system.cal_defn order by name, type";
dsview = new com.borland.dx.dataset.DataSetView();
com.borland.dx.sql.dataset.QueryDescriptor querydescriptor = new
com.borland.dx.sql.dataset.QueryDescriptor(dwa.DWA_Application.database,
sql, dsview, false, Load.ALL);
query = new com.borland.dx.sql.dataset.QueryDataSet ();
query.setAccumulateResults(false);
query.setQuery(querydescriptor);
table = new com.borland.dbswing.JdbTable ();
table.setDataSet(query);
query.executeQuery();
JScrollPane scrollpane = new JScrollPane(table);
grid_panel.add(scrollpane, BorderLayout.CENTER);
this.getContentPane().add(grid_panel, BorderLayout.CENTER);

System.out.println("Query rows = " + query.getRowCount() + " cols= " +
query.getColumnCount());
System.out.println("Table rows = " + table.getRowCount() + " cols= " +
table.getColumnCount());
System.out.println("TableModel rows = " + table.getModel().getRowCount()
+ " cols= " + table.getModel().getColumnCount());
System.out.println("TableColumnModel cols = " +
table.getColumnModel().getColumnCount());
System.out.println("Table Header col count" +
table.getTableHeader().getColumnModel().getColumnCount());


Output
Query rows = 1012 cols= 5 // this is what I expect, why aren't the
others matching this
Table rows = 1 cols= 1
TableModel rows = 1 cols= 1
TableColumnModel cols = 1
Table Header col count1


Back to top
sdf
Guest





PostPosted: Fri Oct 22, 2004 5:29 pm    Post subject: Re: Odd behaviour when using QueryDataSet and JdbTable Reply with quote



Thanks for the quick reply.

I am trying to NOT use the designer as I am building sql on the fly. I
should say that the data does appear perfectly in the application. Its
just that the functions don't seem to work. Is there a certain order
that I need to following in my code?

Please help, thanks.


Paul Nichols (TeamB) wrote:

Quote:
"sdf" <fds (AT) sdf (DOT) com> wrote in message
news:41792b56$1 (AT) newsgroups (DOT) borland.com...

The following is my code to create a QueryDataSet and add it to a
JDBTable. I am requesting a query that has more than 1 row and 1 column
however the JdbTable functions tell me there is only 1 row and 1 column.
I have included some print statments from my program in the "Output"
section. How do I get the right values from JdbTable?


Thanks,

Anthony


Right click on the QueryDataSet from the designer. This should reveal a
QueryDataSet designer that will list all fields. Make sure that they are all
visible. Set the properties as you want them to appear.




Back to top
sdf
Guest





PostPosted: Fri Oct 22, 2004 7:51 pm    Post subject: Re: Odd behaviour when using QueryDataSet and JdbTable Reply with quote



I think I figured out the problem. Although I am not happy with the
situation. It turns out that I tryng to get the number of column prior
to the window being added to a Desktop pane and being made visible. I
have discovered that you should only query the JdbTable tablecolumns
model AFTER the frame is made visible.

Anthony

sdf wrote:
Quote:
Thanks for the quick reply.

I am trying to NOT use the designer as I am building sql on the fly. I
should say that the data does appear perfectly in the application. Its
just that the functions don't seem to work. Is there a certain order
that I need to following in my code?

Please help, thanks.


Paul Nichols (TeamB) wrote:

"sdf" <fds (AT) sdf (DOT) com> wrote in message
news:41792b56$1 (AT) newsgroups (DOT) borland.com...

The following is my code to create a QueryDataSet and add it to a
JDBTable. I am requesting a query that has more than 1 row and 1 column
however the JdbTable functions tell me there is only 1 row and 1 column.
I have included some print statments from my program in the "Output"
section. How do I get the right values from JdbTable?


Thanks,

Anthony


Right click on the QueryDataSet from the designer. This should reveal a
QueryDataSet designer that will list all fields. Make sure that they
are all
visible. Set the properties as you want them to appear.





Back to top
Paul Nichols (TeamB)
Guest





PostPosted: Sat Oct 23, 2004 4:56 pm    Post subject: Re: Odd behaviour when using QueryDataSet and JdbTable Reply with quote


"sdf" <fds (AT) sdf (DOT) com> wrote

Quote:
The following is my code to create a QueryDataSet and add it to a
JDBTable. I am requesting a query that has more than 1 row and 1 column
however the JdbTable functions tell me there is only 1 row and 1 column.
I have included some print statments from my program in the "Output"
section. How do I get the right values from JdbTable?


Thanks,

Anthony

Right click on the QueryDataSet from the designer. This should reveal a

QueryDataSet designer that will list all fields. Make sure that they are all
visible. Set the properties as you want them to appear.



Back to top
Paul Furbacher [TeamB]
Guest





PostPosted: Sun Oct 24, 2004 12:41 am    Post subject: Re: Odd behaviour when using QueryDataSet and JdbTable Reply with quote

sdf wrote:

Quote:
I think I figured out the problem. Although I am not happy with the
situation. It turns out that I tryng to get the number of column prior
to the window being added to a Desktop pane and being made visible. I
have discovered that you should only query the JdbTable tablecolumns
model AFTER the frame is made visible.

Maybe it's related to the fact that UI components aren't
"realized" until shown? Try moving the System.out.println
code to an override of "addNotify()". In that overriding
method, be sure to call super.addNotify() first.


--


Paul Furbacher (TeamB)

Save time, search the archives:
http://www.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder DB Swing All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.