A couple of thoughts:

1) Use a query browser to verify that there actually are rows returned by
your SQL statement.  Which requires that you

2) Examine the query that your code constructs in the debugger.  Construct
your query in a string so you can see it

myString = "Select ... "
rs= app.DirectoryDB.SQLSelect(myString)

3) I would suspect rs.RecordCount, since I recall some discussion of it not
being supported by all databases.  However, if the listbox is actually being
cleared (ie., it HAD contents before you pushed the button and is empty
afterward), then it must at least be nonzero for your code to execute the
RemoveAllRows.  Note that it may still be < 0.

4) As standard practice in debugging, examine all the values that affect the
execution of your code:

Is rs nil?
is rs.RecordCount> 0?
is rs.EOF true immediately following the SQLSelect?

5) It is perfectly legitimate for the SQL to return zero rows and have no
error.  Selecting no rows is not an error in SQL.

6) As an aside, it appears that you are overwriting the value of dTradeName
with dNumber.  When you AddRow, the value goes into cell 0.

I apologize if any of this is a repeat, I didn't see the rest of the thread.

Tim



> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> Jonathon Bevar
> Sent: Friday, October 13, 2006 7:16 PM
> To: REALbasic NUG
> Subject: Re: SQL Query to ListBox help!
>
>
> Dr. Hammond
>
> I took your advise and moved the DB error checking up higher.  As
> far as I
> can tell, I have no idea what I am doing!
>
> There I said it!
>
> It will NOT populate that listbox even when I hard code the name of the
> dTradeName ("Nexuim") into the SQLQuery.  It clears all the rows of the
> listbox fine but thats about it.
>
> I even stripped the program down to its bare parts to work.  Here it is:
>
> CODE:
>   Dim rs as RecordSet
>
>   // Search for Medication or Drug
>   If mdName.text <> "" then
>
>     If mdParameter.text = "Trade Name" then
>       // Search Parameter of TradeName
>       rs = app.DirectoryDB.SQLSelect("SELECT * FROM Directory WHERE
> dTradeName = '" + mdName.text + "'")
>       // rs = app.DirectoryDB.SQLSelect("SELECT dNumber, dTradeName,
> dGenericName, dUsage, dAWC FROM Directory WHERE dTradeName LIKE '%" +
> mdName.text + "%'")
>
>     else
>       MsgBox"Please Select a valid Search Parameter to perform search."
>     end
>
>     // Display Error If One Occurred
>     if App.DirectoryDB.Error then
>       App.DisplayDatabaseError()
>       return
>     end if
>
>     // Show Drugs if they were found
>     If rs.RecordCount <> 0 then
>       // Medication or Drug found
>       // Remove Any Existing Line Items first
>       mdList.DeleteAllRows
>
>       // Add Line Items
>       if rs <> nil and rs.RecordCount > 0 then
>         while rs.EOF = false
>
>           // Add Line Item
>           mdList.AddRow rs.Field("dTradeName").StringValue
>           mdList.Cell(mdList.LastIndex, 1) =
> rs.Field("dGenericName").StringValue
>           mdList.Cell(mdList.LastIndex, 2) =
> rs.Field("dUsage").StringValue
>           mdList.Cell(mdList.LastIndex, 3) = rs.Field("dAWC").StringValue
>           mdList.Cell(mdList.LastIndex, 0) =
> rs.Field("dNumber").StringValue
>
>           // Go to the next record
>           rs.MoveNext
>         wend
>       end if
>
>     else
>       // No Medication or Drug was found
>       MsgBox"There was NO Precription Medication or Drug found by
> that Name
> in the MedDirectory DataBase."
>       // Requery the Database
>       MDQuery.RunQuery
>     End
>
>   else
>     // Error as no Medication or Drug was entered
>     MsgBox"Please enter a Prescription Medication or Drug to search for."
>   end
> END CODE:
>
> I moved the Error checking up more, not sure if that is correct or not.
>
> The ListBox code I foudn in one of my older programs but there is
> a catch.
> the older program used a Main Patient DB then there was a Medication that
> was tied tot he Patient DB as each patient could have unlimited
> medications
> listed for them.  So it uses a LineItemID number.  Anyway I
> played with that
> and no go either.
>
> I am surprised there are no SQL people on here that could jsut show me an
> example of how basicly to get started.
>
> Jonathon
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.408 / Virus Database: 268.13.3/474 - Release Date: 10/13/2006
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>
>
>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to