realbasic-nug
[Top] [All Lists]

Re: Database Date Field Problems

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Database Date Field Problems
From: john roberts <jarobe01 at athena dot louisville dot edu>
Date: Fri, 28 Jun 2002 23:30:51 -0400
on 6/28/02 10:18 PM, Chris Malumphy at cmalumphy at earthlink dot net wrote:

> I use RB as a front end to an Informix database at work. I submit an SQL
> thru RB, it returns a database cursor and I use the code below to place
> the data into a listbox. The code works well, except when one of the
> fields I try to retrieve is a Date field. Then the listbox always shows
> a result of 00-00-00 rather than a real date. When I look at the data
> using any other tool, I get a proper date. Any ideas as to what I'm
> doing wrong?

In my (very limited) exposure to Informix Databases, the date fields were
extremely complex and could be returned in a variety of ways. It may be that
to use the stringValue in a way that RB can use you have to specify a
specific format for the dateField value. Other than that, I don't see a
problem with your usage of stringValue. Perhaps others can spot something.

In a slightly different vein, in lieu of
> 
> while not dbcursor.eof
> for n = 1 to nfields
> if n = 1 then
> nrecords = nrecords + 1
> listBoxResults.addrow dbcursor.idxField(n).stringValue
> else
> listBoxResults.cell(listboxResults.lastindex, n-1) =
> dbcursor.idxField(n).stringValue
> end
> next
> dbcursor.movenext
> wend
> 

you might try

  while not dbcursor.eof
    nrecords = nrecords + 1
    listBoxResults.addrow dbcursor.idxField(1).stringValue
    lastLine = listboxResults.lastindex// *** new local variable !!!
    for n = 2 to nfields
      listBoxResults.cell(lastLine, n-1) = dbcursor.idxField(n).stringValue
    end
    dbcursor.movenext
  wend

Basically it avoids repeated use of the if-then and makes use of a local
variable rather than looking up listboxResults.lastindex. Both of these
should gain you a little speed.

In any case, I hope this helps.
John



<Prev in Thread] Current Thread [Next in Thread>