The code below works fine if I rename the .dbf to something with equal or less then eight characters before the extension.
Unfortunately the dbf is created by another program and is updated a few times per hour, so renaming it all the time is the last on my list of options to fix this problem.
So I used the GetShortPathName function, but that introduced the next problem.
I think the tilde ~ causes a syntax error, but as I'm very new to .NET I don't know how to fix it. Hopefully it is something simple.
Who can help me with this?
TIA for your time.
PS F:\\ and \\Fileserver\DATA\ point to the same location
Unfortunately the dbf is created by another program and is updated a few times per hour, so renaming it all the time is the last on my list of options to fix this problem.
So I used the GetShortPathName function, but that introduced the next problem.
I think the tilde ~ causes a syntax error, but as I'm very new to .NET I don't know how to fix it. Hopefully it is something simple.
'get datetime Dim Vandaag As DateTime = DateTime.Today 'extract the year Dim jaar As String = Vandaag.ToString("yy") 'put the year in the filename Dim bestandsnaam As String = "F:\ICONNECT\tracerap_" & jaar & ".DBF" 'shorten the filename bestandsnaam = GetShortFileName(bestandsnaam) 'and grab the last 12 characters bestandsnaam = bestandsnaam.Substring(bestandsnaam.Length - 12, 12) 'the result for this year is TR39C1~1.DBF 'set up the query Dim ConnectionString As String ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Fileserver\DATA\ICONNECT;Extended Properties=dBase IV" Dim dBaseConnection As New System.Data.OleDb.OleDbConnection(ConnectionString) dBaseConnection.Open() Dim QueryString As String = "SELECT * FROM " & bestandsnaam 'this line is where the syntax error is reported Dim dBaseCommand As New System.Data.OleDb.OleDbCommand(QueryString, dBaseConnection) Dim dBaseDataReader As System.Data.OleDb.OleDbDataReader = dBaseCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Who can help me with this?
TIA for your time.
PS F:\\ and \\Fileserver\DATA\ point to the same location