Solved

bind text file name(directory) into a dataset

Posted on 2006-06-18
4
244 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

17 Experts available now in Live!

Get 1:1 Help Now