Indeed, can be extended to intercept the command shell error, rest is the same, in the end it is one big string that is deliverd to SHELL.
But with EXEC, it seems to be different: separate parameters are to be delivered and it is not clear how to deliver the part with the sql file: This does not work: EXEC ["mysql", sUser, sPassword, sHost, sDatabase, sImport, sSqlFile] WAIT It gives: mysql Ver 14.12 Distrib 5.0.45, for suse-linux-gnu (i686) using readline 5.2 .. etc I am most in doubt about ' ... sImport = "<" sSqlFile = Application.Path & "/mytables.sql" Probably the file should not be passed as text parameter? When changing the user, password, host, database I get "normal" errors like: EXEC ["mysql", sUser, sPassword, sHost, "wrongdatabase"] WAIT Gives: ERROR 1049 (42000): Unknown database 'wrongdatabase' > > to save your base you can use this Gambas command. > > SHELL "mysqldump" & " " & "-u" & " " & db.Login & " " & "-p" & db.Password > & " > " & "Name-of-your-base" & " " & "--add-drop-table" & " " & ">" & " " & > User.home & "/Name-of-your-base.sql" & " 2>/tmp/result" WAIT > > > To restore your base you can use this. > > IF IsNull(db.Password) THEN 'if no password > SHELL "mysql" & " " & "-u" & " " & db.login & " " & > "Name-of-your-base" & > " " & "<" & Sauves.Text & "/Name-of-your-base.sql" & " 2>/tmp/result" WAIT > ELSE > SHELL "mysql" & " " & "-u" & " " & db.login & " " & "-p" & db.Password > & " > " & "Name-of-your-base" & " " & "<" & Sauves.Text & > "/Name-of-your-base.sql" & > " 2>/tmp/result" WAIT > ENDIF > > Note: 2>/tmp/result is for intercept the command shell error > > I hope this script help you. > > Cordialement. > > Jacky > >> >> I couldn't get it to work with EXEC; >> >> sImport = "< " & Application.Path & "/mytables.sql" >> ' ... >> EXEC ["mysql", sUser, sPassword, sHost, sDatabase, sImport] >> >> Everything works fine except the last part that gives the file to read >> from. >> >> I get the general help of mysql, not a specific error like when I change >> the password to a wrong one. >> >> Maybe there is a difference between the normal parameters and the way to >> give the file to import from? >> >> >> I could get it to work with SHELL though: >> >> sImport = "< " & Application.Path & "/mytables.sql" >> '... >> sCommand = "mysql " & sUser & " " & sPassword & " " & sHost & " " & >> sDatabase & " " & sImport >> DEBUG sCommand >> SHELL sCommand WAIT >> >> Ok! Don't know which is the "preferred" way but this works. >> >> >> > You could use the EXEC command to run the appropriate mysqlsomething >> > utility (don't recall which) >> > >> > Regards >> > Werner > Le mardi 16 décembre 2008 12:20:06 wig, vous avez écrit : >> > wig wrote: >> >> Although I can create table by table from within Gambas with >> >> hCon.Databases.Add(sDbName), I wondered if there is a way to "import" >> a >> >> mysql dump file, so that I can create the tables with data (in one >> >> command). >> >> >> >> Untill now I allways used phpMyAdmin dump/export and import for >> creating >> >> the database structure and initial data, but I want to integrate it >> in >> >> my >> >> Gambas application. >> > ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user