New topic: insertion of new sql rows question
<http://forums.realsoftware.com/viewtopic.php?t=41319> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message WarpedChild Post subject: insertion of new sql rows questionPosted: Fri Nov 04, 2011 7:46 pm Joined: Tue Sep 06, 2011 4:42 pm Posts: 7 I want to use the index of a for/next loop to specify the values to be inserted in new rows of an SQL database. The following code represents just a learning tool but should illustrate my problem. The database exists and contains currently a single (or more if I wanted to hand code it) row in the table "calendar" with columns, id = 1, month = January, days = 31 Specifically an error code is returned, "no such column i"... etc. when I attempt to insert more rows using the following code. Is there a way to do this? Dim dbFile as FolderItem Dim db2 as REALSQLdatabase db2=New REALSQLdatabase dbFile= NEW FolderItem("db2.rsd") db2.databaseFile=dbFile dim nums(12) as Integer // this is to create days/month as f(i) nums(1) = 31 nums(2) = 28 nums(3) = 31 nums(4) = 30 nums(5) = 31 nums(6) = 30 nums(7) = 31 nums(8) = 31 nums(9) = 30 nums(10) = 31 nums(11) = 30 nums(12) = 31 dim mo(12) as string // creates (month) as g(i) mo(1) = "January" mo(2) = "February" mo(3) = "March" mo(4) = "April" mo(5) = "May" mo(6) = "June" mo(7) = "July" mo(8) = "August" mo(9) = "September" mo(10) = "October" mo(11) = "November" mo(12) = "December" dim i as integer if db2.connect then for i = 2 to 12 db2.SQLexecute ("Insert into calendar (id, month, days) Values (i, mo(i), nums(i))") // db2.SQLexecute ("Insert into calendar (month, days) Values (mo(i), nums(i))") // this won't work either without explicit i. next If db2.error then MsgBox db2.ErrorMessage else db2.Commit //save insert MsgBox "Record updated successfully." end if end if Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- 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]
