Hi All,
I have a module which uploads the excel file selected to the folder portals. The sample path is as follows C:\Inetpub\wwwroot\sample4.7\Portals\0\import.xls. The file is being uploaded correctly but i get an error when i try to import the data in excel to the database. I have written both functionalities upload and import functionality in the same button clickk event. Code is as follows for the event.
Private Sub cmdAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAdd.ClickTry
Dim strFileName As String
Dim strExtension As String = ""
Dim strMessage As String = ""
Dim postedFile As HttpPostedFile = cmdBrowse.PostedFile'Get localized Strings
strFileName = System.IO.Path.GetFileName(postedFile.FileName)
strExtension = Path.GetExtension(strFileName)
Dim strInvalid As String = Services.Localization.Localization.GetString("InvalidExt", Me.LocalResourceFile)If postedFile.FileName <> "" Then
Select Case FileTypeCase UploadType.File ' content files
strMessage += FileSystemUtils.UploadFile(RootFolder, postedFile,
False)End Select
Else
strMessage = Services.Localization.Localization.GetString(
"NoFile", Me.LocalResourceFile)End If
Dim excelConnection As System.Data.OleDb.OleDbConnectionDim ExcelPath As String = PortalSettings.HomeDirectoryMapPath & postedFile.FileName'Fetch data from excel
excelConnection =
excelConnection.Open()
Dim ExcelCommand As New System.Data.OleDb.OleDbCommandNew System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source='" & ExcelPath & " '; " & "Extended Properties=""Excel 8.0;HDR=No;IMEX=1""")
etc .. and code to import.
But the file is being uploaded correctly and when the excelconnection.open is executed it throws the following error.
Error: upload is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Unspecified error ---> System.Data.OleDb.OleDbException: Unspecified error at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open() at XWD.Modules.XWD_DNN_CompetencyManager.Upload.cmdAdd_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\sample4.7\DesktopModules\XWD_Comp_AdminManager\upload.ascx.vb:line 95 --- End of inner exception stack trace
What might be the problem. The folder has the file and the connection is not being opened.please help its really urgent
Thanks,
Sandeep.M