Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Sep 19, 2019 3:50 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Writing multiple records FROM listbox TO REALSQLDatabase
PostPosted: Thu Jan 17, 2013 5:50 am 
Offline

Joined: Fri Oct 26, 2012 6:24 am
Posts: 72
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.

_________________
Stuart J Sykes - www.real-soft.co.uk
Mountain Lion 10.8.2 (Real Studio 2012 2.1)


Top
 Profile  
Reply with quote  
 Post subject: Re: Writing multiple records FROM listbox TO REALSQLDatabase
PostPosted: Thu Jan 17, 2013 6:45 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
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

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Writing multiple records FROM listbox TO REALSQLDatabase
PostPosted: Thu Jan 17, 2013 8:50 am 
Offline

Joined: Fri Oct 26, 2012 6:24 am
Posts: 72
Thanks Akiland - I'll give it a try and get back.

_________________
Stuart J Sykes - www.real-soft.co.uk
Mountain Lion 10.8.2 (Real Studio 2012 2.1)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group