Solved

bind text file name(directory) into a dataset

Posted on 2006-06-18
4
245 Views
Last Modified: 2010-04-23
Hi Experts,

Would like to bind some of the text files from fixed directory into a dataset. How can i do it??? Pls provide me the code..

0
Comment
Question by:nyee84
  • 2
  • 2
4 Comments
 

Author Comment

by:nyee84
ID: 16929577
experts pls help
0
 
LVL 34

Expert Comment

by:Sancler
ID: 16929835
I am not sure if I am alone in this, but I don't understand your question.

Normally, a reference to "binding" involves the linking of some property of some control/s with data that is held in a datasource.  Although there can be a variety of datasources, a dataset is not one of them (although a datatable within a dataset can be).

What you are asking about, however, is "binding" some files to a dataset.  Files are not controls that can be "bound" in the sense that I have just described, and a dataset is not a datasource to which controls can, anyway, be "bound" in that sense.

So what is it you are actually trying to do?  Do you want to create a datasource containing file names (and perhaps other details of the files) and bind some control - e.g. a listbox - to that?  Or are you trying to create a datasource for which the data comes from some text file/s and bind some control - e.g. a textbox - to that?  Or what?

And what version of VB.NET are you using?

Roger
0
 

Author Comment

by:nyee84
ID: 16929859
Hi Roger,

I am using .net framework 1.1 and basically my program checking content of  text files in a directory and some reasons i need to display the some of the text files name in a datagrid.

I need to store the text filenames in a datatable so that i can do databinding and can display in a  grid and it was very unfortunate that i dont know how to store txtfile name in a datatable so that i can do a databing to my grid.

Pls advice
0
 
LVL 34

Accepted Solution

by:
Sancler earned 500 total points
ID: 16930273
Try this

One form with one datagrid on it.  Just this code

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("c:\")
        Dim Files() As System.IO.FileInfo = myDir.GetFiles("*.txt")
        DataGrid1.DataSource = Files
    End Sub

You will obviously need to play with it.  For instance, the directory it reads is c:\ and I imagine you will want to change that.  And the datagrid shows more information than you might need.  But it illustrates a simple way of displaying file information in a datagrid.  Will that, with suitable adjustments, do what you want?

Roger
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Round a string to two digits 12 32
Parallel.ForEach using SendMailAsync() detect when loop is complete 24 58
Get list of word ducuments in a folder 10 36
vb.net 2 37
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now