Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

bind text file name(directory) into a dataset

Posted on 2006-06-18
4
Medium Priority
?
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

636 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