[Gambas-user] Extracting fields from a Result

Doug Hutcheson owlbrudder at gmail.com
Mon Jan 1 08:47:08 CET 2018



On Mon, 2018-01-01 at 16:19 +1000, Doug Hutcheson wrote:
> On Sun, 2017-12-31 at 16:23 -0500, T Lee Davidson wrote:
> > On 12/31/2017 03:16 PM, Tobias Boege wrote:
> > > On Sun, 31 Dec 2017, T Lee Davidson wrote:
> > > > Yes, MyResult!txtMasterDatabase should work. (Did you
> > > > copy/paste that name, or type it in directly?) The For Each
> > > > loop should
> > > > work as well.
> > > > 
> > > > I tried a simple command-line application on a MySQL data table
> > > > with just one row. All the application does is, first connect
> > > > to
> > > > the database, and then 'MyResult = hConn.Exec("select * from
> > > > users")'
> > > > 
> > > > A For Each loop prints the field names just fine. And, 'Print
> > > > MyResult!id' displays the correct value.
> > > > 
> > > > Perhaps there is a bug in the Gambas PostgreSQL driver. Can you
> > > > test on a MySQL table to see if that works for you?
> > > > 
> > > 
> > > I agree that the original code should have worked. See the
> > > attached
> > > script which uses an in-memory SQLite3 database to demonstrate
> > > that
> > > it works with another driver.
> > > 
> > > A (minimal!) project and database dump, just enough to reproduce
> > > the
> > > behaviour, would be helpful.
> > > 
> > > Regards,
> > > Tobi
> > 
> > I installed a PostgreSQL server. PostgreSQL does not appear at
> > first glance to be as easy to work with as MySQL.
> > 
> > After finally figuring out how to configure and use it, I was able
> > to run a simple command-line application to successfully
> > print the field names. (Interestingly enough, even without the
> > gb.db.postgresql database driver component enabled! Benoît?)
> > 
> > It does work as you expect it should, Doug.
> > 
> > You will find my code and the output below.
> > 
> > 
> Thanks Lee and Tobi (and others) for sticking with me on this.
> 
> I can now report s follows:
> 
> For a PostgreSQL object on my machine:
> An indexed For ... Next loop works fine
> A For Each ... Next always fails at the first line - see attached
> image. Gambas is reporting it can't find a field of a given name, but
> it has to have found it in order to report its name.
> 
> For a MySQL (MariaDB) connection on my machine, both forms of loop
> work fine.
> 
> Using the Connection option from the project window, I can see and
> browse all data in both types of database.
> 
> So, it appears to be a glitch in the way the code is executed in a
> For Each loop on a PostgreSQL object. Having said that. I have
> previously had issues with executables from the Fedora repositories
> misbehaving, so I installed Gambas from the Gambas repositories
> instead and proved the issue was still there.
> 
> Lee has reported different behaviour, so something is definitely
> screwy on my system. Sigh.
> 
> How do I prepare my project and transmit it to the list?
> 
> Kind regards,
> Doug
> 
Hi everyone. Another piece of the puzzle, I think:

I have a Database Application where I have been experiencing the above
problems. Within this application I have one form which I have hardly
been using. I have also created two Connections, one for my PostgreSQL
database and one for my MySql database.

As the two connections are able to browse their respective databases,
it seemed logical that controls using these connections would work
also. I created a DataSource control on my form and set its Connection
property to Connection1 (my PostgreSQL database). When I run the
project, I am told "Cannot open database: fe_sendauth: no password
supplied". I then set the Connection property to Connection2 (my MySql
connection). When I run the project I am told "Cannot open database:
Access denied for user 'root'@'localhost' (using password: NO)"

Why am I seeing these password problems when the Connection objects
they are using connect perfectly?

It seems to me I have some kind of data access issue related to my
specific installation, because others are not reporting these.

Incidentally, the data-aware controls look excellent! I will be able to
develop my applications faster that I had imagined.

I have reverted to using Gambas 3.10.0 from the Fedora 28 repositories,
to eliminate any finger fumbles I may have had when compiling from
source. If requested, I can switch back again.

Cheers,
Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180101/58b76600/attachment.html>


More information about the User mailing list