[Gambas-user] More on properties ...

Benoit Minisini gambas at ...1...
Sun Apr 29 23:58:35 CEST 2007


On dimanche 29 avril 2007, Gareth Bult wrote:
> 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.
>

I'm eager to see your DBGridEdit!

-- 
Benoit Minisini




More information about the User mailing list