I have this code i need to retrieve a path from a VBScript variable and use it with a mysql query.

set fso = WScript.CreateObject("Scripting.FileSystemObject")
Mypath = fso.GetAbsolutePathName(".")
Fullpath = fso.buildpath(Mypath,"test.txt")

then later in the code i need to launch a query with:

obj.sql(extQuery)

extQuery = "select * from table_name into outfile '?????'.....

What do i need to do to get the path from my variable and use it in the query ? Hope someone could show me an example. Thanks !

1

There are 1 best solutions below

6
On BEST ANSWER

You use string concatiantion

obj.sql(extQuery)

extQuery = "select * from table_name into outfile '" & Fullpath  &  "'....


extQuery = "SELECT *  INTO OUTFILE '" & Fullpath   & "'
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
  LINES TERMINATED BY '\n'
  FROM table_name ;".

You have also to add

 Fullpath = Replace(Fullpath , "\", "/") 

As the \is an escape parameter in mysql