New topic: 

Writing multiple records FROM listbox TO REALSQLDatabase

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

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        Stuart J Sykes          Post subject: Writing multiple records 
FROM listbox TO REALSQLDatabasePosted: Thu Jan 17, 2013 5:50 am                 
        
Joined: Fri Oct 26, 2012 6:24 am
Posts: 40                I'm having trouble with the coding for writing 
multiple records FROM a listbox TO my database
The Database is created and open - It has 1 table (table1) it has 5 fields 
code, name, homephone, mobilephone, comments (all text fields except code which 
is a hidden INTEGER PRIMARY KEY field)
Iv'e imported a CSV file (created in Excel) using code into the ListBox (all 
works fine) and now need to write the ListBox records to the database but cant 
seem to make it work - cant figure out how to loop through the listbox records 
and write them individually.   
                             Top                Akiland          Post subject: 
Re: Writing multiple records FROM listbox TO REALSQLDatabasePosted: Thu Jan 17, 
2013 6:45 am                                 
Joined: Tue Jan 04, 2011 3:02 am
Posts: 1109
Location: Jönköping, Sweden                To be honest I don't know if this 
is the right way in SQLite. This is how you can do it in MySQL.
But you get the idea of how to loop through the Listbox 
Dim i as Integer
Dim sql as String

For i = 0 to Listbox1.RowCount-1
  sql = "INSERT INTO table1 (code, name, homephone, mobilephone, comments) 
VALUES(" + Listbox1.Cell(i,0) +", '" + Listbox1.Cell(i,1) + "', '" + 
Listbox1.Cell(i,2) + "', '" + Listbox1.Cell(i,3) + "', '" + Listbox1.Cell(i,4) 
+ "');"
  db.SQLExecute(sql)
  if db.Error = True then
  //Handle error
  end if
Next
      
_________________
 http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
REAL.Studio Web Edition 2011r3  
                             Top                Stuart J Sykes          Post 
subject: Re: Writing multiple records FROM listbox TO REALSQLDatabasePosted: 
Thu Jan 17, 2013 8:50 am                         
Joined: Fri Oct 26, 2012 6:24 am
Posts: 40                Thanks Akiland - I'll give it a try and get back.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 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