简体   繁体   中英

Select String in odbc query

is there any posibility to select a string in an odbc query? i want select the sum of many excel sheets and also need the name of the excel sheet in the resulting pivottable, so i tried something like this:

strSQL = "SELECT Sum(`table" & i & "`.`Stunden`), " & GetFilenameFromPath(arrFiles) & " FROM [" & strSheet & "$] `table" & i & "` WHERE `table" & i & "`.`Stunden` IS NOT NULL"

but the select statement " & GetFilenameFromPath(arrFiles) & " does not work right... a select of 1 works instead! eg:

strSQL = "SELECT Sum(`table" & i & "`.`Stunden`), 1 FROM [...]

do i have to escape the string in any form?

thanks

Well, GetFilenameFromPath will return you a string, so you need to encase this in quotes:

strSQL = "SELECT Sum(`table" & i & "`.`Stunden`), '" & GetFilenameFromPath(arrFiles) & "' FROM...

Although, I'd encourage you to be more explicit in your question. Details of the expected output of GetFilenameFromPath for you, and a specific error message would be very helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM