Application Note for QuNect ODBC for QuickBase
Backing up a Quickbase table to a CSV file with VBScript
This VB Script will open up a Quickbase table specified by the DBID on the command line and write it's contents to the console or to a file. The field names will appear as the first row of the output. You can find the DBID of your Quickbase table by reading the How to Find the DBID of a Quickbase Table application note.
Copy the code at the bottom of this page to the clipboard and paste the contents into a blank Notepad document. Save the Notepad document using a Save as type of All Files and an Encoding of ANSI. Use the file name QuNectBackupToCSV.vbs. Remember where in the file hierarchy you saved the file. After you've saved the file you'll need to open up a command prompt window. You can do this by Start->Run...->cmd. Then you'll need to navigate to the directory where you saved the QuNectBackupToCSV.vbs file. The command line for the script needs to look like this:
cscript //NoLogo //U QuNectBackupToCSV.vbs yourdbid > yourbackupfile.csv
You'll need to replace the yourdbid with the DBID of your Quickbase table. Also you should replace yourbackupfile.csv with a filename of your choice. If you want to use a DSN other than QuickBase via QuNect then you can supply your DSN's name like this on the command line:
cscript //NoLogo //U QuNectBackupToCSV.vbs yourdbid "Your Own QuNect DSN Name" > yourbackupfile.csv
If you want to backup file attachments, simply configure your DSN to download file attachments. This feature is available only with the 2011 version of QuNect ODBC for QuickBase.
if WScript.arguments.count < 1 then WScript.echo "Please supply at least one command line parameter." WScript.echo "The first command line parameter should be the dbid of the Quickbase table that you want to backup." WScript.echo "The second optional command line parameter should be the DSN." WScript.echo "In the absence of a second command line parameter the DSN 'QuickBase via QuNect' will be used." WScript.echo "The command line should look like this:" WScript.echo "cscript //NoLogo //U QuNectBackupToCSV.vbs yourdbid optionalDSN > yourbackupfile.csv" WScript.echo "The above command line will backup the table with a dbid of yourdbid to the file yourbackupfile.csv" WScript.Quit(-1) end if Dim Conn Dim rs Set Conn = CreateObject("ADODB.Connection") dim connectionString dim DSN DSN = "QuickBase via QuNect" if WScript.arguments.count = 2 then DSN = WScript.arguments.item(1) end if connectionString = "DSN=" & DSN & ";" Conn.Open connectionString Set Rs = CreateObject("ADODB.Recordset") Rs.Open "select * from """ & WScript.arguments.item(0) & """" , Conn dim i dim line if Rs.BOF then WScript.echo "The table contains no records." WScript.Quit(-2) end if for i = 0 to Rs.Fields.count - 1 line = line & """" & replace(Cstr(Rs.fields(i).name), """", """""") & """," next WScript.echo line do while not Rs.EOF line = "" for i = 0 to Rs.Fields.count - 1 if isnull(Rs.fields.item(i)) then line = line & "," else line = line & """" & replace(Cstr(Rs.fields.item(i)), """", """""") & """," end if next WScript.echo line Rs.movenext() loop Conn.close