Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > Tab Import does not work with Microsoft.Jet.OLEDB; CSV works even though FMT=TabDelimited
 

Tab Import does not work with Microsoft.Jet.OLEDB; CSV works even though FMT=TabDelimited

I am trying to import a tab delimited file with ADO. If I convert my tabs to csv it works, but I would like to know why it does not work with tab.
TheFunction is on the buttom
here is my test data:

Test1:
- Create a Text file with Headers: Test1, Test2, Test3
and rows:
row1: 1,2,3; row2: 4,5,6; row3: 7,8,9

I create the file in Excel and export it from excel, if I read it back in as a delimited file it recognizes the tabs and displays it correctly.

here is the test file in hex:
54 65 73 74 31 09 54 65-73 74 32 09 54 65 73 74 |Test1.Test2.Test|"
33 0D 0A 31 09 32 09 33-0D 0A 34 09 35 09 36 0D |3..1.2.3..4.5.6.|"
0A 37 09 38 09 39 |.7.8.9 |"


I followed link:
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/9ac36a61-8556-4b50-861e-11db2d36b1d1/
but it does not help me

My output in my datagrid is:
Test1_Test2_Test3 for the header
1|2|3, the | is really a square box which indicates the Tab I suppose.
4|5|6
7|8|9
I binged and googled and yahooed and now I am ready to do a snore..

I hopeyou guys can help me

====

Function ImportTab(ByVal StrFileName As String) As Boolean

Dim StrSql As String = ""
Dim strCSVConnStr = ""
Dim myString As String = ""
Dim strfile As String = ""

ImportTab = False
Try

strfile = StrFileName

Dim myConnection As New System.Data.OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\AlarmData;" & _
"Extended Properties='text;FMT=TabDelimited;HDR=YES'")

myConnection.Open()

StrSql = "Select * From [TabData.txt] ;"

Dim oleAdapter1 As New OleDb.OleDbDataAdapter(StrSql, myConnection)

Dim dtbCSV As New DataTable
oleAdapter1.Fill(dtbCSV)
DataGridView1.DataSource = dtbCSV
DataGridView1.Focus()
ImportTab = True

Catch ex As System.InvalidOperationException
Debug.Write(ex.Message)
ImportTab = False
End Try

End Function

###################

Just found that If I use a normal txt file with comma separated content then thisfunction will display it correctly. It is like the fmt has no function.

Steffen064  Wednesday, November 25, 2009 4:41 AM
Hi Steffen,

the default delimiter of the Jet Engine can be found in the registry here : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text in the key Format

you can either change it there, or bettercreate a file named Schema.ini and put it in the same directory as your textfile.

The Schema.ini should look like:

[yourtextfilename.txt]
Format=TabDelimited

you can get further information about the Schema.ini file here: http://msdn.microsoft.com/en-us/library/ms709353(VS.85).aspx
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
  • Marked As Answer bySteffen064 Thursday, November 26, 2009 3:46 PM
  •  
Heslacher  Thursday, November 26, 2009 8:08 AM
Hi Steffen,

the default delimiter of the Jet Engine can be found in the registry here : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text in the key Format

you can either change it there, or bettercreate a file named Schema.ini and put it in the same directory as your textfile.

The Schema.ini should look like:

[yourtextfilename.txt]
Format=TabDelimited

you can get further information about the Schema.ini file here: http://msdn.microsoft.com/en-us/library/ms709353(VS.85).aspx
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
  • Marked As Answer bySteffen064 Thursday, November 26, 2009 3:46 PM
  •  
Heslacher  Thursday, November 26, 2009 8:08 AM
Hi
My schema.ini file looks like this

[TestTab.txt]
ColNameHeader=True
Format=TabDelimited
Col1="Test1" Long
Col2="Test2" Long
Col3="Test3" Long

And it worked.
I did have a schema file without the file name and that did not work.
Thank you so much
Steffen
Steffen064  Thursday, November 26, 2009 3:48 PM

You can use google to search for other answers

Custom Search

More Threads

• Visual Basic 2008 app setting file or my.settings question
• create new object of type (type of another object) ... or better solution
• Lock users out of Windows?
• Filling datagridview
• Help please!
• Windows Service Fails to Start (No Work To Do)
• DataGridView - Combobox - Problems!!
• Reading Text File Problem
• Enum question
• VB.NET Chat App + Multi Connections