[馨郁星愿] .net 操作Excel的问题!
System.Data.OleDb.OleDbException: Microsoft Jet 数据库引擎打不开文件 ' '。 它已经被别的用户以独占方式打开,或没有查看数据的权限。 at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) at System.Data.OleDb.OleDbConnection.InitializeProvider() at System.Data.OleDb.OleDbConnection.Open() at BJWeb.Mass.ExcelToString()
很奇怪的问题,本地机器测试通过,而到服务器上利用服务器上的浏览器执行程序也通过,但是我用我本地机器访问服务器,执行的时候就报错了~~~
这是为何?很不理解,请大家帮忙~~~附上代码:
Public Function ExcelToString() As String
Dim imagePath As String '文件路径
Dim imageType As String '文件类型
If Not FileUp.PostedFile.FileName Is Nothing Then
imagePath = FileUp.PostedFile.FileName
'取得文件类型
imageType = imagePath.Substring((imagePath.LastIndexOf( ". ") + 1))
If "xls " <> imageType Then
Response.Write( " <script language= 'javascript '> alert( '对不起!请您选择Excel文件! '); </script> ")
Return " "
Else
Try
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source= " + imagePath + "; " + "Extended Properties=Excel 8.0; "
Dim conn As OleDbConnection = New OleDbConnection(strConn)
conn.Open()
Dim i As Integer
Dim sb As New System.Text.StringBuilder