Good Morning
I have some code which connects to a CSV folder like this:
Sub getDataFromSheets()
Dim oResult As Object
Dim tblName$
Dim srcTempRs As Object, srcRs As Object
Dim tdsppmExists As Boolean
Dim srcSQL$, colNames$
Dim daCol As New Collection
Dim dataSrc$
dataSrc ="Y:\"
getSdbcFlatFileConnection(dataSrc)
oResult = csvCon.getMetaData().getTables(null, "%", "%", Array("TABLE"))
End Sub
sub getSdbcFlatFileConnection(fileLoc As String)
Dim sURL$
Dim myDict As Variant
myDict= getScriptForgeDictionary()
With myDict
.Add("Extension", "csv")
.Add("HeaderLine", True)
.Add("FieldDelimiter", " ")
.Add("StringDelimiter", """")
.Add("DecimalDelimiter",".")
oParms = .ConvertToPropertyValues()
.Dispose()
End With
sURL="sdbc:flat:" & fileLoc
csvCon= getConnectionWithUserInfo(sURL, oParms)
End sub
private Function getConnectionWithUserInfo(sURL As String,oParms As Variant) As com.sun.star.sdbc.XConnection
Dim oManager As object
oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
getConnectionWithUserInfo= oManager.getConnectionWithInfo(sURL,oParms)
End Function
Function getScriptForgeDictionary() As Variant
if not GlobalScope.BasicLibraries.isLibraryLoaded("ScriptForge") Then
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
End If
getScriptForgeDictionary= CreateScriptService("Dictionary")
End Function
This code works fine. However the Y: drive maps to an UNC path. I would like to however use the UNC path instead of the mapped drive. When I use the UNC path, I get the following error:
BASIC runtime error.
An exception occurred
Type: com.sun.star.sdbc.SQLException
Message: The URL “file://server/full_unc_path” is not valid. A connection cannot be created..
So does anyone have any idea to connect to an UNC path?