Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 11 to 14 of 14 total |
Change Database from the same session at runtime |
Thu, Nov 10 2016 8:56 AM | Permanent Link |
Raul Team Elevate | On 11/9/2016 10:10 PM, KimHJ wrote:
> Each time I need a new database I would then have to add the new database to the Database Manager and compile and deploy. Database manager is for the IDE design time (and used by internal web server) so you only need to add this if you need access to data during development. Normally (production) you just add it to EWB Web Server - Database tab. You don't need to re-compile and re-deploy your app if it's just new DB and structure is same as before - nothing changes in your code except actual database name and if that is retrieved during login from database (your user id, database name table) then this is set in code and your app would be unchanged. > Even I don't create a TDatabase unit for each database as long as I have them in the EWB Database Manager I can access them after the project is Deployed? Yes - most people (including me) only use the built-in database object and just set the name as needed to know which back-end database to connect to. > Will that say that all the settings for all the Databases in the Database Manager in the EWB is deployed with every project even I if don't create a TDatabase unit? None of this is deployed - database manager is an IDE design tool. (if you create your own TDatabase units then yes that is deployed but that has nothing to do with database manager entries directly either). most of the time in EWB app you just need "datasets" that define dataset name and columns and link to other data-aware controls. Then you can use built-in database and just set the name properly. > If I could get this filter to work I think it would be a better way. It's your app but one downside with this is that you need to include your param with everything so all your queries (IMHO) become lot more work (you have to create them with params in the back end and in code). You also have to give all users access to all other users data - separate databases would allow you to use EDB security on a per user basis. Note that at the end of the day all of these data queries are simply HTTP calls so it's trivial to determine what your app is calling and then i could try to run some of my own using just browser. > CustID: String; > CustID := '1000'; > Database.DatabaseName:='Mydata'; > StoreTbl.Params.Clear; > StoreTbl.Params.Add('CustomerID=''' + CustID + ''''); > LoadRows(StoreTbl); > > I get all rows what is missing? You likely did not specify dataset properly. if you're going to use params then your dataset definition (in the database manager) must be something like this (row source tab): Based on Query and for example this : SELECT * from datatbl WHERE CustomerID={CustomerID=''} then you can do this in code CustID := '1000'; CustData.Params.Clear; CustData.Params.Add('CustomerID=' + QuotedStr(CustID)); Database.LoadRows(CustData); and it should load fine. see more here: http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Creating_Loading_DataSets Raul |
Thu, Nov 10 2016 1:55 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Kim,
<< Since all Dataset's are identical in Fcustomer BCustomer and in the same session I'm surprise that there is no way to change it. >> The database name is defined globally in the server, changing it would change it for *all* connections. Raul's suggestion to use a web server module is the best solution to this. It will allow you to dynamically deal with the database names as they come in, and hook them up to the correct database before processing each request. The only other option is to just copy and paste the dataset definitions from one "reference" database in the EWB IDE/Web Server into the other databases. << My other option was to have all data in one database and use a Customer id column to only show each customer their data, is there away to apply a filter before LoadRows? >> To perform filtering, you provide parameters in the EWB client TDataSet instance and then set up your dataset(s) on the server side to use these parameters: http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Creating_Loading_DataSets Feeding expressions into the server-side is a security issue, so that's why you can't just send arbitrary filter expressions to the server. Tim Young Elevate Software www.elevatesoft.com |
Thu, Nov 10 2016 5:56 PM | Permanent Link |
KimHJ Comca Systems, Inc | Raul wrote:
On 11/9/2016 10:10 PM, KimHJ wrote: >>> Even I don't create a TDatabase unit for each database as long as I have them in the EWB Database Manager I >>>can access them after the project is Deployed? >>Yes - most people (including me) only use the built-in database object >>and just set the name as needed to know which back-end database to >>connect to. Ok I think I got it now, I din't realize that I had to enter the databases in the EWB server and give them the same name I have in my project, that was what confused me. I did a test and the Database.DatabaseName:='FCustomer'; have no effect I had to us the class name of the unit before it worked. Database1.DatabaseName:='FCustomer'; I have two Units with the TDatabase class is that why? Thanks, Kim |
Fri, Nov 11 2016 8:42 AM | Permanent Link |
Raul Team Elevate | On 11/10/2016 5:56 PM, KimHJ wrote:
> I did a test and the > Database.DatabaseName:='FCustomer'; > have no effect I had to us the class name of the unit before it worked. > Database1.DatabaseName:='FCustomer'; > I have two Units with the TDatabase class is that why? Yes - you have to change the database that is the owner of the dataset. In your case I assume you created a new database and then dropped datasets on it so this database is now owner of those datasets so you would need to do things like Database1.DatabaseName:='FCustomer'; and Database1.LoadRows(myDataset) etc. Datasets dropped on forms would default to the built-in database (and you'd need to do Database.DatabaseName:='FCustomer' in that case). Since you have all of this already then i would just continue using it - if you want you can have 1 database unit you created with datasets on them and just change the name like you did above and it should all work as long as you use this database (Database1) for all database operations. Raul |
« Previous Page | Page 2 of 2 | |
Jump to Page: 1 2 |
This web page was last updated on Wednesday, March 27, 2024 at 05:29 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |