[Gambas-user] prb:Connection.Exec() bypass sql code
ron
ronstk at ...239...
Sun Apr 30 00:08:58 CEST 2006
On Saturday 29 April 2006 23:41, Benoit Minisini wrote:
> On Saturday 29 April 2006 23:34, ron wrote:
> > I'm feeling realy stupid.
> > ===========
> > PRINT sTBLinProc
> > hRecordData = hConn.Create(sTBLinProc)
> > i = hRecordData.Fields.Count
> > i = hRecordData.Count
> > i = hRecordData.Max
> >
> > txtCount.Text = getRecordCount()
> > ===========
> > hRecordData is variable of Result
> > sTBLinProc = table name and correct
> > the first i is correct field count
> > the second i is gives '1' and is wrong, the test table has 7 records
> > the last i returns '0' and should be 6 ?
> >
> > The GetRecordCount() I made get it from the same table and is correct.
> >
> > The help says only
> > 'This class represents the result of a SQL request.'
> > 'Returns the number of records inside the result.'
> >
> > Than it is logic to me that 'hRecordData = hConn.Create(sTBLinProc)'
> > should act as the SQL request and get the whole table as
> > "SELECT * FROM table" and if there is a note in gb.db
> > page not to use .Exec for correct working.
>
> Not at all. Create() returns a special read/write Result with one record
> inside.
>
> All record fields are set to NULL, that means, in the Create() case only, that
> the field will take its default value.
>
> Are things clearer?
It explains my findings, but clearer, I can't say that.
I do ATM not understand the purpose of such record.
Or do I have to understand .Create(tblname) is a method
to create a new record wich is added to he tblname after hConn.Update ?
May I suggest in that case to add a method .UseTable(tablename as string)
that do the "select * from tablename" and a .MoveFirst() automatic.
In that way you can direct use the Result without additional commands.
hResult = hConn.UseTable("mytable")
for each hResult
print hResult["fieldname"] ' do something
next
>
> Note: If you want to see what 'gb.db' sends to the database backend, set
> DB.Debug to TRUE at the start of your program.
Good tip, as normal from you :)
>
> Regards,
>
Mail problem was at provider, maintenance yesterday with problems, and
two havy used video streams icm birthday queen will also had influence.
Ron
More information about the User
mailing list