I build a array of inserts - first item in the array is "begin transaction"
i19 = i19 + 1 sql = "Insert into disks " sql = sql & "( diskno,dirno, nof,disknum, dirnum) " sql = sql & "Values ('" sql = sql & i17 & "', '" & i3 & "', '" & i20 & "', '" & tmp19 & "', '" & tmp15 & "');" rcnt = rcnt + 1 qrs2[rcnt] = sql ' ' ' lots of code omitted ' ' I insert records in blocks of 10,000 to speed up insert rather than single inserts but feel free to insert one rec at atime if you wish ' IF rcnt > 10000 THEN rcnt = rcnt + 1 qrs2[rcnt] = "commit;" FOR i7 = 1 TO rcnt databaseconnection.Exec(qrs2[i7]) NEXT rcnt = 1 qrs2[rcnt] = "begin transaction;" ENDIF ' ' ' This is how I do it. Do some error checking to make sure your single quotes and special chars are taken care of - have fun. Ivan \~/ I never saw a wild thing sorry for itself. A small bird will drop frozen dead from a bough Without ever having felt sorry for itself. -- D.H. Lawrence http://www.usconstitution.net/const.html Linux - Live Free or Die. ________________________________ From: M. Cs. <mohar...@gmail.com> To: mailing list for gambas users <gambas-user@lists.sourceforge.net> Sent: Monday, February 6, 2012 9:18 AM Subject: Re: [Gambas-user] How To INSERT INTO in MySQL? And I agree with Fabien!!!! I just over with the transcription of former wrongly formatted query style -> query="INSERT INTO....." MyConn.Exec(query) Don't use that style! You will make only troubles with escaping characters. The right way is MyConn.Exec("INSERT Into ... VALUES(&1,&2...);",myvar1,myvar2,...) 2012/2/6, Fabien Bodard <gambas...@gmail.com>: > sql = "INSERT INTO statistic (TimeCode, SessionStart, SessionEnd, Kluch, > Comp) VALUES (&1,&2,&3,&4,&5)" > MODMain.$Con.Subst(sql, T, Now(), Now(), kluch, Nc) > MODMain.$Con.Exec(sql) > > > ???? > > i prefer like that : > > MODMain.$Con.Exec("INSERT INTO statistic (TimeCode, SessionStart, > SessionEnd, Kluch, Comp) VALUES (&1,&2,&3,&4,&5)",T, Now(), Now(), > kluch, Nc) > > ------------------------------------------------------------------------------ > Try before you buy = See our experts in action! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-dev2 > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user