Re: [Gambas-user] More on properties ...
Brought to you by:
gambas
From: Gareth B. <ga...@en...> - 2007-04-29 21:31:20
|
Ok, What I'm doing for now is to have a string property in my DBGridEdit called "DBConnection". This is the "name" of a component type "DBConnection", which I use to "wrap" a raw "Connection". Logic: "Connections" do not type things timeouts and disconnects, which are common, esp. over the Internet. I have a method called Exec; PUBLIC SUB Exec(cmd AS String) AS Result RETURN $conn.Exec(cmd) CATCH Connect() RETURN $conn.Exec(cmd) END Where Connect is; PRIVATE SUB Connect() WITH $conn .host = $host .type = $type .user = $user .Password = $pass END WITH TRY $conn.Close $conn.Open END This transparently handles reconnection in the event that a connection has timed out .. which catches / fixes 99% of all my sql errors :-) Effectively I have a DBGridEdit component that subclasses my GridEdit component, but includes a connection and sql statements .. so I can pretty much get 98% of my code into DBGridEdit's property boxes at design time .. so effectively I plonk a DBGridEdit onto a tab strip, set myDBGridEdit.Criteria to the "where" component of a query, then do myDBGridEdit.Open and I'm off. The GridEdit handles all keystrokes etc etc nicely .. and the DBGridEdit tracks changes, handles the editor and writes stuff back to the DB transparently. Reduces many days (or even weeks) of coding to (literally) minutes for anything that needs to edit a DB on a grid. I've also included an integral button bar .. indeed I've been trying to write a component that will allow me to mimick "Navicat"'s DB editor, but with a more modern feel .. hopefully it will make a rather nice drop in replacement for the Gambas Database manager's data editor ... :-) Anyway, another day or two so and I should have something to show off ... ;-) (but it would be really nice to get the extensions in place to handle user/gambas-written components "fully" .. there are LOTS of historical components knocking around from Kylix days that would be easy to re-implement in Gambas .. I've already re-written an SMTP server module which is archiving all my incoming email into an SQL db... currently ~ 10,000 emails without a crash :-)) Gareth. On Sun, 2007-04-29 at 22:24 +0200, Benoit Minisini wrote: > On dimanche 29 avril 2007, Gareth Bult wrote: > > Still pressing on ... > > > > I can see the method for filling a static combo box for a components > > properties .. > > > > I want to link a My GridEditor to a Connection component .. is there a > > neat way of filling a property combo with a list of all components > > within the application of a given type ? > > (so effectively setting the contents of the drop down to a list of > > components of type "DBConnection") > > > > ?? > > > > Gareth. > > > > Not at the moment, but this is planned for the next release after 2.0. > > This release will be a 2.2 or maybe a 3.0, I don't know yet. > > I want to merge the database manager and the IDE, and to make the IDE managing > different form types: report forms, web forms, for example. And consequently, > I will need to manage properties like you did. > > At the moment, I suggest you do like me in the gb.db.form component: always > use the current connection, by using the DB static class. > > Note that I have never used Delphi, I don't know it at all, so maybe you will > have many ideas for Gambas that I don't imagine :-) > > Regards, > -- Gareth Bult, Encryptec Limited Tel: 0845 25 77033, FWD: 753977, Mob: 07891 389657 Email: ga...@en..., MSN:gar...@ho... Statements made are at all times subject to Encryptec's Terms and Conditions of Business, which are available upon request. |