Link to home
Start Free TrialLog in
Avatar of Ernesto
ErnestoFlag for Mexico

asked on

connection needed for upload text over 250 characters in excel

hi, im trying to export a excel file to db with a module, all works find until the text is so long in the case of the fiel desciption that im atached it is
im ussing this conection
 
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.jet.OLEDB.4.0; " & _
                               "data source='" & PrmPathExcelFile & " '; " & "Extended Properties=Excel 8.0;")

im attaching the problem file as well
tsm
LM-Valvulas-Rev1.xls
Avatar of ScriptAddict
ScriptAddict
Flag of United States of America image

Looks like this might be solved by moving a copy of the file to your c:\Temp or something like that, and running it from there.

That should dramatically reduce the size of the database connection if you are suffering from a long path.  

Or just move it to somewhere with a much shorter path.  Could you map a drive to the location of file?  Would that also work to reduce the file path size?

If you break up the connection string does that fix it?  

 mycn.connection = mycn.connection & blah blah more?
Avatar of Ernesto

ASKER

tsm
thats not the problem,
the problem is if you see the file  the "DESCIPTION" column,
do not do the process if the cell continues in an other line like the most,
ej
"VALVULA DE COMPUERTA INSERTO SOLDABLE CLASE 800 API, CUERPO ASTM A105, INTERIORES DE ACERO INOXIDABLE 316, DISCO Y ASIENTO RECUBIERTO DE ESTELITA, CUERDA EXTERIOR Y YUGO, BONETE ATORNILLADO, CUÑA SOLIDA, ASIENTOS RECAMBIABLES, OPERADA CON VOLANTE. NACE MR-01-75"
from
" OPERADA CON VOLANTE. NACE MR-01-75" is in the row bellow that  cause fail to the process"
>im trying to export a excel file to db with a module

What DB is it and what is the length of description field in DB?
Avatar of Ernesto

ASKER

is 512,
the problem isnt there, the problem is when pass the excell sheet to the datagreed.

from the datagrid i have a migration proccess that do it well, the problem is show up the sheet in the datagrid.
tsm
So, just to clarify.  

The issue here is that when your automated import process has a line that is longer then excel will allow in a single cell, and splits it in two cells, the second cell crashes the import.

?
No. He is importing from excel not exporting to it.

>when pass the excell sheet to the datagreed.


Can you show the code which is used to import excel to your grid?
Avatar of Ernesto

ASKER

ok, the procces is when import to the grid
the code to puts the excell file to the grid is the next
event click
 Private Sub Btn_Import_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Import.Click
        Try
            Dim _Obj As New ExcelConnection1
            _Obj.ImportAttendence(Txt_Path.Text, DataGrid1)
            '_Obj.ImportAttendence(Txt_Path.TextLength, DataGrid1)

        Catch ex As Exception

        End Try
    End Sub

**** then


 Public Class ExcelConnection1


#Region "Public Function(s)"

        Public Function ImportAttendence(ByVal PrmPathExcelFile As String, ByVal DataGrid1 As DataGrid)

            Dim MyConnection As System.Data.OleDb.OleDbConnection

            Try

                ''''''' Fetch Data from Excel

                Dim DtSet As System.Data.DataSet

                Dim MyCommand As System.Data.OleDb.OleDbDataAdapter


                '  MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
                '                 "data source='" & PrmPathExcelFile & " '; " & "Extended Properties=Excel 8.0;")


                MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.jet.OLEDB.4.0; " & _
                               "data source='" & PrmPathExcelFile & " '; " & "Extended Properties=Excel 8.0;")



                ' Select the data from Sheet1 of the workbook.

                MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [sheet1$] where desciption<>'' and spec<>''order by spec,req_cta,desciption asc", MyConnection)
                'MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [sheet1$] where desciption<>'' and spec<>''order by desciption asc", MyConnection)

                MyCommand.TableMappings.Add("Table", "Attendence")

                DtSet = New System.Data.DataSet

                MyCommand.Fill(DtSet)
                '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                DataGrid1.DataSource = DtSet.Tables(0)
                MyConnection.Close()

            Catch ex As Exception
                MyConnection.Close()
                MsgBox("Error de Datos", vbCritical)
            End Try

        End Function

#End Region



    End Class

End Module
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ernesto

ASKER

tsm