Skip to Content
0
Jun 15, 2020 at 02:39 PM

Failed to import data to a hana schema table using vb.net

332 Views Last edit Jun 15, 2020 at 11:22 PM 4 rev

Hi Experts,

I want to import excel sheet directly into an internal table in the hana schema of sap hana 1.0 that is used by SAP Business One 9.3 For Hana. The excel sheet consists of some data. There is only one sheet and have 20 columns.

The excel sheet is exported from mysql using an application that developed by using vb.net of vs. 2015 or 2010 and then import it to hana schema table. The table name is Invoice_AR in hana schema and in mysql schema.

When the importing take places, the system prompts error. The screen shot of error message as follows:

I have created same column types between mysql schema table and hana schema table. I didn't use double in mysql schema table fields. I also don't use column type 'system.init32'.

Is there any change during the Importing of excel data in the system?

This is the code I am using:

Private Sub ImportToHana(FullFileName As String)

        Dim filenam As String
        filenam = FullFileName
        Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filenam + " ;Extended Properties=""Excel 12.0 Xml;HDR=Yes""")
        ExcelConnection.Open()
        Dim expr As String = "SELECT * FROM [Sheet1$]"
        Dim objCmdSelect As OleDbCommand = New OleDbCommand(expr, ExcelConnection)
        Dim objDR As OleDbDataReader

        Dim SQLconn As New HanaConnection()
        Dim sConn As String = ""
        sConn = "Server=" & sSAPServerName & _
                                ";Current Schema =" & sSAPDbName & _
                                ";UseTrusted=False" & _
                                ";UserID=" & sSAPDbUserName & _
                                ";Password=" & sSAPDbPassword

        SQLconn.ConnectionString = sConn
        SQLconn.Open()

        Using bulkCopy As HanaBulkCopy = New HanaBulkCopy(SQLconn)
            bulkCopy.DestinationTableName = "AR_Invoice"

            Try
                objDR = objCmdSelect.ExecuteReader
                bulkCopy.WriteToServer(objDR)
                objDR.Close()
                SQLconn.Close()
                MsgBox("Data's are imported to SQL Succesfully", MsgBoxStyle.Information)
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        End Using
    End Sub

Please help to solve this issue.

Thanks in advance.

Rgds,

Steve

Attachments