|
<< Click to Display Table of Contents >> Navigation: Telegram > 2020 > 10 > 29 > Telegram_2020-10-29T14 |
2020-10-29T14:02:07
I'm perplexed... It's not like I am trying to do something complicated ;)
2020-10-29T14:02:53
after your page loads and you can see that there are rows displaying — add a button that reads a value from the dataset and write it to a TIWLabel, just for debug purposes
2020-10-29T14:03:07
if you can see the text there, then it's simply a grid issue
2020-10-29T14:03:25
Also — quick question — are you pooling your data module?
2020-10-29T14:08:47
No pooling, that was the default when I create it, and I had no idea what that meant so I left it ;)
2020-10-29T14:09:04
The grid is populating with data from my query just fine...
2020-10-29T14:09:33
so the problem is solved?
2020-10-29T14:12:36
No, the grid will only display data if I do not assign any columns
2020-10-29T14:13:09
Interestingly, when I try setting a label caption to a value from my data, I get a \This page isn't working\ (code 500) in my browser...
2020-10-29T14:13:30
All I'm doing is setting Caption to FieldByName().AsString
2020-10-29T14:13:55
in what lifecycle event are you opening the data?
2020-10-29T14:14:07
IWButton.OnClick
2020-10-29T14:14:43
that will work
2020-10-29T14:15:28
It does
2020-10-29T14:15:35
...unless I define cloumns?!
2020-10-29T14:15:49
OK, let me try it myself
2020-10-29T14:16:27
I am going to try moving the data components out of my data module and into the UserSessionUnit. Perhaps that is confusing things somehow?
2020-10-29T14:16:50
the user session is a data module, basically
2020-10-29T14:17:25
and everything that you want in your session — that you don't want other users to see — has to go on your session
2020-10-29T14:17:42
You I just had a lot of premade stuff I wanted to loop in from a data module so I used that...
2020-10-29T14:18:08
so — the db connection needs to go on the session — so that each user gets their own
2020-10-29T14:18:21
because most db connection components are NOT thread safe
2020-10-29T14:18:28
Right
2020-10-29T14:18:37
which is why I pool my data connections
2020-10-29T14:18:44
otherwise I get thousands of connections to the db
2020-10-29T14:19:04
which doesn't make sense on several levels
2020-10-29T14:19:22
the amount of memory used on the server would be crazy
2020-10-29T14:19:23
I was instantiating the data module in the UserSession create event anyway, but this is such a simple application that containing what I need in the usersession will be fine
2020-10-29T14:19:31
and the db engine wouldn't appreciate so many connections to it
2020-10-29T14:19:40
I see
2020-10-29T14:19:52
OK, I'll go try a TIWDBGrid and I'll report back
2020-10-29T14:20:14
Thank you so much! I will let you know if moving things into the user session works
2020-10-29T14:26:13
OK removed my secondary data module entirely. Grids still work the same, only now I can set the label caption without errors
2020-10-29T14:27:13
I think I was referncing the data module directly instead of the one the usersession owned so it was likely throwing an access violation
2020-10-29T14:27:37
in your page/form — do NOT put the user session unit in your uses clause
2020-10-29T14:27:56
you can only get access to your UserSession through your ServerController
2020-10-29T14:28:18
the ServerController has a special function whose only job is to give you access to your session
2020-10-29T14:30:00
It is not... I am setting the IWDBGRid.DataSource to UserSession.dsTest at runtime
2020-10-29T14:30:11
good
2020-10-29T14:33:45
So is assigning iwdbg1.DataSource := UserSession.dsTest correct? i.e. referencing hte usersession in this way is valid?
2020-10-29T14:34:00
I mean it must be?! Since the label and grids work
2020-10-29T14:34:59
if your UserSession is the function in the ServerController — then you are golden
2020-10-29T14:35:04
Yup
2020-10-29T14:35:34
It just returns Result := TIWUserSession( type: link WebApplication.data );
2020-10-29T14:35:46
But that's all boilerplate stuff, I have not touched it'
2020-10-29T14:38:42
Were you able to get an IWDBGrid to display properly with columns defined?
2020-10-29T14:38:52
This has to be a grid problem as the data seems to be working properly
2020-10-29T14:38:58
still working on it
2020-10-29T14:57:26
I guess following the isolation logic (of restricting data stuff to the usersession) there is no way to assign the .DataSource property of databound controls at design time?
2020-10-29T14:57:48
I have seen people do it temporarily, in order to get design-time data
2020-10-29T14:58:02
But I have also seen people forget to remove the pieces afterwards
2020-10-29T14:58:49
Only way I can see to do that would be to add the UserSessionUnit to the main form's uses clause which kind of violates the separation
2020-10-29T14:59:10
yes
2020-10-29T14:59:44
I have weaned myself away from design-time data when developing web apps
2020-10-29T14:59:58
OK well that makes sense... I will do the same