forlano Messages: 1185 Registered: March 2006 Location: Italy
Senior Contributor
michael wrote on Wed, 23 May 2007 07:40
There is another problem.
I have defined an object of class1 with global scope:
class1 global;
Then i use it in class2 like this:
String a_string = global.datagrid.Get(1);
datagrid is a sqlarrayctrl and a member of class1.
But i can't get any data from the datagrid, a_string is always empty.
Any tips?
Michael
I've never used sqlarrayctrl. Anyway, are you sure you have correctly initialized class1 and populated datagrid?
Moreover, I suggest you to post your test package to easily catch the error.
michael Messages: 153 Registered: May 2007 Location: Germany
Experienced Member
After testing for a while it seems that reading data from the datagrid doesn't work because there is no row selected.
Here is what i'm doing:
1.
I start my application, it reads some data from an sql-table and shows them in a sqlarrayctrl which is placed in my first topwindow.
2.
Then i open a editdialog (2nd topwindow) which tries to get the data from datagrid. The result is empty.
3.
I tried to get the selected row by using datagrid.GetCursor to check what going on and the result is -1 which means there is no row selected. This is the reason why there is no data as a result of using datagrid.Get(1) for example.
I think the problem is that i try to get the data after opening a new topwindow (my editdialog).
mrjt Messages: 705 Registered: March 2007 Location: London
Contributor
It's pretty difficult to guess whats wrong becuase the there are many ways in which you could have configured the control. However, my best guess is that you are calling the wrong function.
In the simplest case I believe calling ArrayCtrl::Get(x) will return the contents of Column x on the current cursor row. If there is no cursor row you will get nothing.
I think you probably want to use either GetLine(row), which returns an array of values from a row, or Get(row, column) to get the value of a particular field.