Will see if I can get that .bat file working. Thanks again. One thing I will need to figure out is how to notify VB that all is finished. I suppose I could run a loop at the end of my VB procedure checking for something, but I couldn't see anything suitable (amongst the dot commands) that VB could check for. Maybe the .bat file should show at the end to tell the user things are finished. I now run the .bat file from VBS, so I can make it run invisible.
RBS -----Original Message----- From: Griggs, Donald [mailto:[EMAIL PROTECTED] Sent: 15 November 2006 19:37 To: sqlite-users@sqlite.org Subject: RE: [sqlite] Importing text file via .bat file Echo .mode csv >MyCommands.tmp Echo .import ReadCode.txt ReadCode >>MyCommands.tmp Sqlite3 ReadCode.db ".read myCommands.tmp" ============================= -----Original Message----- From: RB Smissaert [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 15, 2006 1:13 PM To: sqlite-users@sqlite.org Subject: RE: [sqlite] Importing text file via .bat file Hi Donald, Thanks, but I don't quite get it yet. What is in this file MyCommand.tmp? Is there no way to put the whole thing in on .bat file or even better run the whole sequence from VB? RBS =============================== =============================== Regarding: "What is in this file MyCommand.tmp?" The file, "MyCommand.tmp" would be a temporary file created by your batch file itself as it runs. Regarding: "...one batch file...?" In a sense, the entire logic *is* in one batch file, but it's true that a small, temporary file is created as part of the process, and you can delete it when done. Unless you're doing this thousands of times an hour, the extra time introduced by having a temporary file will be minimal. Kees Nyut showed a nicer syntax, one that I *thought* I had problems with for early versions of sqlite.exe under windows, but seems to work well now: Instead of: Sqlite3 ReadCode.db ".read myCommands.tmp" use: Sqlite3 ReadCode.db <myCommands.tmp Re: "..or VB?" I don't use Visual Basic, so I'm no expert, but the advantage of using the sqlite command-line utility (called sqlite3.exe) is that the code for parsing comma-delimited strings is built in. If you have your routines for this, or want to incorporate the code from the sqlite command utility source, then you can certainly do everything within VB. Returning to the "single batch file" question: I've actually used a sneaky means of doing this, but it assumes you're pretty familiar with batch files. It's more straightforward for unix scripts, but for windows, we start it with a line of /* Which gives a (harmless) error when the batch file starts, but it allows us to treat the top portion of the file as a set of inputs to sqlite command utility. -----beginning of file Mybatchfile.bat /* GOTO :startit This is a combination sql and batch file to ....... */ /* Put all your sql commands and DOT commands here */ drop table if exists ReadCode; create table ReadCode ( SUBJECT_TYPE varchar(5), READ_CODE varchar(5), TERM30 varchar(30), TERM60 varchar(60) ); .mode csv .import ReadCode.txt ReadCode -- end sqlite with .quit, but batch file continues .quit == nothing runs in this space till we get to "startit" ==================== :Startit Rem Beginning of batch file commands @echo off Rem clear the harmless error off the screen Cls Rem [Do any other preparatory batch file commands here] Rem Invoke sqlite3 command utility and submit the top of this batch file as a set of commands Rem we assume this entire batch file is named "Mybatchfile" and it's in our current directory. Sqlite3 myData.db <MyBatchFile.bat Rem [ put here any windows batch commands we want after Sqlite3 leaves with the .quit command ] ----end of mybatchfile.bat ---------------------------------------------------------------------------- - To unsubscribe, send email to [EMAIL PROTECTED] ---------------------------------------------------------------------------- - ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------