Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
I am uploading a excel sheet and want its data two be moved to another table in database i m getting this error from last two days moreover if i design a very simple application it works fine Please Help me.

Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("TERAMSConnectionString").ConnectionString)
            Dim path As String = FileUpload1.PostedFile.FileName
            Dim excelConnectionString As String = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + (path + ";Extended Properties=Excel 12.0;Persist Security Info=False"))
            Dim excelConnection As OleDbConnection = New OleDbConnection(excelConnectionString)
            conn.Open()
            excelConnection.Open()
            Dim cmd As OleDbCommand = New OleDbCommand("Select * from [Sheet1$]", excelConnection)
            'Clears any previous data
            Dim sClearSQL = "DELETE FROM Desktop_Compare "
            Dim SqlCmd As SqlCommand = New SqlCommand(sClearSQL, conn)
            SqlCmd.ExecuteNonQuery()
            Dim dReader As OleDbDataReader = cmd.ExecuteReader
            Dim sqlBulk As SqlBulkCopy = New SqlBulkCopy(conn)
            excelConnection.Close()
            conn.Close()
        End Using 







Line 74: Dim excelConnection As OleDbConnection = New OleDbConnection(excelConnectionString)
Line 75: conn.Open()
Line 76: excelConnection.Open()
Line 77: Dim cmd As OleDbCommand = New OleDbCommand("Select * from [Sheet1$]", excelConnection)
Line 78: 'Clears any previous data
Posted
Comments
thatraja 24-Oct-13 9:50am    
Include complete error message
Dave Kreskowiak 24-Oct-13 23:30pm    
Without knowing the exception message it's impossible to help you.
Ankit Mishra 25-Oct-13 9:16am    
Issue is solved and - The Exception was System.Data.OleDb.OleDbException reason was error with name of control in the aspx page.
Dave Kreskowiak 25-Oct-13 9:29am    
That's the exception TYPE, not the exception MESSAGE.
thatraja 25-Oct-13 9:10am    
Glad, you have solved the issue.

1 solution

Closed. Fixed the problem himself.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900