文件名的特别字符 导致数据库连不上?求解答
2012.02.25_d3.csv 有这样一个文件
我用以下方法数据库连接
DS = getDataset("select top 1 * from " & safefilename & " where [F4] = 'Mid-M 70%' order by [F2],[F3] desc", Filepath)
'FilePath为该CSV所在文件夹,safefilename为该文件文件名
Function getDataset(ByVal sql As String, ByVal path As String) As DataSet
Try
Dim connstr As String = "Provider=Microsoft.jet.OLEDB.4.0;Data Source= " & path & "\;Extended Properties=""text;HDR=no;FMT=Delimited"""
Dim conn As OleDbConnection = New OleDbConnection(connstr)
Dim adapter1 As OleDb.OleDbDataAdapter = New OleDbDataAdapter(sql, conn)
Dim cmd As OleDbCommand = New OleDbCommand
Dim commandBuilder As OleDbCommandBuilder = New OleDbCommandBuilder(adapter1)
getDataset = New DataSet
adapter1.Fill(getDataset, "temp")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function