473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Displaying Text File in a Table

What is the easiest way to display in a table, a delimited
text data saved in a text file?

I need an idea so that I can research it!

Amjad
Nov 20 '05 #1
5 1401
Cor
Hi Amjad,

Just an idea to research

Use a "datatable" and a "datagrid" from which that datatable is the
datasource
(You need for the to create the datatable, the "datarow" 's and the
"datacolumn" 's )

Then you can read your text file using the "streamreader".

While reading record by record you "split" every row using the delimiter

For every row you read you make a datarow which you fill from the splitted
string array.

I think that if you have researched it, your text will be on your screen.

All the words between the "" are words you can look for on/in MSDN, there
are a lot of examples

I hope this was where you where looking for?

Cor
What is the easiest way to display in a table, a delimited
text data saved in a text file?

I need an idea so that I can research it!

Amjad

Nov 20 '05 #2
Assuming you have a Schema.ini file available for use you can use code like
this:

Public Sub FillTable(ByRef ds As DataSet, ByVal TableName As String, ByVal
Path As String)
Dim strConn, strSQL, strFileTitle, strFileFolder As String
strFileTitle = Path.GetFileName(Path )
strFileFolder = Path.GetDirectoryName(Path )

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source=" & strFileFolder & ";"
strConn &= "Extended Properties=Text"

strSQL = "SELECT * FROM [" & strFileTitle & "]"

Dim dt As DataTable
Dim da As OleDbDataAdapter
Dim cnn As New OleDbConnection(strConn)
Dim cmd As New OleDbCommand(strSQL, cnn)
Try
cmd.CommandType = CommandType.Text
cnn.Open()
da = New OleDbDataAdapter(cmd)
da.Fill(ds, TableName)
Finally
cnn.Close()
End Try
End Sub

--
Joe Fallon

"Amjad Farran" <an*******@discussions.microsoft.com> wrote in message
news:3c****************************@phx.gbl...
What is the easiest way to display in a table, a delimited
text data saved in a text file?

I need an idea so that I can research it!

Amjad

Nov 20 '05 #3
Assuming you have a Schema.ini file available for use you can use code like
this:

Public Sub FillTable(ByRef ds As DataSet, ByVal TableName As String, ByVal
Path As String)
Dim strConn, strSQL, strFileTitle, strFileFolder As String
strFileTitle = Path.GetFileName(Path )
strFileFolder = Path.GetDirectoryName(Path )

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source=" & strFileFolder & ";"
strConn &= "Extended Properties=Text"

strSQL = "SELECT * FROM [" & strFileTitle & "]"

Dim dt As DataTable
Dim da As OleDbDataAdapter
Dim cnn As New OleDbConnection(strConn)
Dim cmd As New OleDbCommand(strSQL, cnn)
Try
cmd.CommandType = CommandType.Text
cnn.Open()
da = New OleDbDataAdapter(cmd)
da.Fill(ds, TableName)
Finally
cnn.Close()
End Try
End Sub

--
Joe Fallon

"Amjad Farran" <an*******@discussions.microsoft.com> wrote in message
news:3c****************************@phx.gbl...
What is the easiest way to display in a table, a delimited
text data saved in a text file?

I need an idea so that I can research it!

Amjad

Nov 20 '05 #4
To display the results:
On a form just add a DataGrid and bind it to your datatable:

DataGrid1.DataSource = dsMain.Tables(strTableName).DefaultView
--
Joe Fallon

"Amjad Farran" <an*******@discussions.microsoft.com> wrote in message
news:3c****************************@phx.gbl...
What is the easiest way to display in a table, a delimited
text data saved in a text file?

I need an idea so that I can research it!

Amjad

Nov 20 '05 #5
To display the results:
On a form just add a DataGrid and bind it to your datatable:

DataGrid1.DataSource = dsMain.Tables(strTableName).DefaultView
--
Joe Fallon

"Amjad Farran" <an*******@discussions.microsoft.com> wrote in message
news:3c****************************@phx.gbl...
What is the easiest way to display in a table, a delimited
text data saved in a text file?

I need an idea so that I can research it!

Amjad

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Waguih Boctor | last post by:
Hi, I have a number of ASP pages where some JPGs and GIFs are displaying in the browser and some are not. I have included an excerpt from the HTML below. In this example, the gif file at the...
4
by: Stephen | last post by:
I have an xml document with a xsl stylesheet. It will display the styles in explorer, but not in netscape 7.1 <?xml version="1.0" standalone="no"?> <!DOCTYPE home SYSTEM...
14
by: Akbar | last post by:
Hey there, Big-time curiosity issue here... Here's the test code (it's not that long)... it's to display a large number of image links with captions, ideally pulled in from an external file...
1
by: Mark ??;-\) | last post by:
I would like to display a listing of files on a web page as follows: If there is only one file: display the section name and then display the current file. If there is more than one file (for...
0
by: Fronky | last post by:
Hope someone can help. I am still learning, so no laughing please. I am displaying records from a database using Response.Write(""); instead of the usual datagrid method. I am doing it this way...
3
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
1
by: kamkoum | last post by:
Hello, I am using readxml to retrieve data from an xml file to a dataset. m xml file has hierarchical data (2 levels) so the dataset will contain tables. My question : I need to display...
1
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
7
by: hsegoy1979 | last post by:
Dear All Iam using file upload control and i want to display image in another pop up page .But image is not displaying in image control iam sending image path thru querystring . here is my code ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.