New topic: 

RESOLVED Populate PopupMenu from a database?

<http://forums.realsoftware.com/viewtopic.php?t=47147>

         Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic          Author  
Message        RicSum          Post subject: RESOLVED Populate PopupMenu from a 
database?Posted: Mon Mar 04, 2013 7:13 am                         
Joined: Fri Jun 05, 2009 4:54 pm
Posts: 427
Location: London, England                I have a database called 
"Settings.db", which contains 1 table called "SettingsTable", and various 
columns - (the column I need to use is called "Sonames").

I gathered various code from the LR and a couple of old posts from users and 
came up with the code below.
All I need to do is populate PopupMenu2 with the names which are listed in the 
"Sonames" column of my database.

The database is already open, so I just need help with the code to actually 
populate the PopupMenu.


 Dim dbRec As New DatabaseRecord
Dim stSql As String
Dim recSet As RecordSet
Dim dBse As New REALSQLDatabase
Dim dbFile As FolderItem
Dim intI, intLast As Integer

dbFile = GetFolderItem("Settings.db")
dBse.DatabaseFile = dbFile

//Test to ensure connected.
If dBse.Connect = True Then
  stSql = "SELECT Sonames FROM SettingsTable"
  recSet = dBse.SQLSelect(stSql)
  
  if recSet = nil then
  msgbox "SQL Error: "+ dBse.ErrorMessage
  
  else
  while not recSet.EOF
  win_Add.PopupMenu2.AddRow recSet.Field("Sonames").StringValue
  recSet.MoveNext
  wend
  end
end if


When I view the PopupMenu, all I get is a large empty white square drop down 
from the popup (as if there are 20 or so invisible entries) ??
All help appreciated ! Also, could the problem be with the path to the database 
file?

Thank you all in advance.      
_________________
RealStudio Professional Edition 2012 r2
Developing on OS X  10.8 (Mountain Lion)
Deploying on Windows XP / 7 / 8      

    Last edited by RicSum on Mon Mar 04, 2013 7:35 pm, edited 2 times in total. 
  
                             Top                pfargo          Post subject: 
Re: Populate PopupMenu from a database?Posted: Mon Mar 04, 2013 10:09 am        
                 
Joined: Mon Oct 13, 2008 4:26 am
Posts: 37                Put a breakpoint in your code and step through it in 
the debugger.
You test for a connection but give no indication if it fails.   
                             Top                RicSum          Post subject: 
Re: Populate PopupMenu from a database?Posted: Mon Mar 04, 2013 11:52 am        
                 
Joined: Fri Jun 05, 2009 4:54 pm
Posts: 427
Location: London, England                OK,
I am now soooooooooo confused as I have been trying to solve this stupid newbie 
problem for 14 hours !!!!!!!!!!!
I am now more than happy to pay someone who knows what the hell they are doing, 
to create the snippet for me.

Here are the details:

Database Location = A subfolder from my main app, called "Support Files"
Database File Name = Settings.db
Database Table = "SettingsTable"
Database Column = "Sonames"
PopupMenu Name = "PopupMenu2" (located in a window called "win_Add")


All I need is for "PopupMenu2" to be populated by the entries contained within 
the database column called "Sonames"
The actual database is already open due to being opened upon startup.

If anyone is kind enough, please let me know the cost and I will pay you 
upfront for the snippet.

I have tried my hardest but this ridiculous problem is now making me feel ILL.

Thank you.     
_________________
RealStudio Professional Edition 2012 r2
Developing on OS X  10.8 (Mountain Lion)
Deploying on Windows XP / 7 / 8  
                             Top                markwalsh          Post 
subject: Re: Populate PopupMenu from a database?Posted: Mon Mar 04, 2013 12:00 
pm                         
Joined: Wed May 20, 2009 4:43 pm
Posts: 943                RicSum wrote:OK,
I am now soooooooooo confused as I have been trying to solve this stupid newbie 
problem for 14 hours !!!!!!!!!!!
I am now more than happy to pay someone who knows what the hell they are doing, 
to create the snippet for me.

Here are the details:

Database Location = A subfolder from my main app, called "Support Files"
Database File Name = Settings.db
Database Table = "SettingsTable"
Database Column = "Sonames"
PopupMenu Name = "PopupMenu2" (located in a window called "win_Add")


All I need is for "PopupMenu2" to be populated by the entries contained within 
the database column called "Sonames"
The actual database is already open due to being opened upon startup.

If anyone is kind enough, please let me know the cost and I will pay you 
upfront for the snippet.

I have tried my hardest but this ridiculous problem is now making me feel ILL.

Thank you. 
The code that you posted, where is it located? Is it in the popupmenu's 'Open' 
event? The window's event? Did you put a breakpoint in your code as suggested? 
Try changing
win_Add.PopupMenu2.AddRow recSet.Field("Sonames").StringValueto
Dim soName as string
soName = recSet.Field("Sonames").StringValue
// Check value of soName to make sure it is what you expect
win_Add.PopupMenu2.AddRow soName

Also, what is win_Add? Is that the name of the window, or a window subclass? 
Depending on where you have your code, this could be the problem.      
_________________
RB 2009r4 Windows XP      

    Last edited by markwalsh on Mon Mar 04, 2013 9:35 pm, edited 1 time in 
total.   
                             Top                RicSum          Post subject: 
Re: Populate PopupMenu from a database?Posted: Mon Mar 04, 2013 7:34 pm         
                
Joined: Fri Jun 05, 2009 4:54 pm
Posts: 427
Location: London, England                Thanks everyone - I have managed to 
achieve my objective.   
I completely changed my attempt, but still have no idea why the previous 
snippet didn't work?

Thank you all once again.      
_________________
RealStudio Professional Edition 2012 r2
Developing on OS X  10.8 (Mountain Lion)
Deploying on Windows XP / 7 / 8  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to