473,785 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataBinding using a sequential file

I am new to vb.net and I am running into problems understanding
DataBinding and its concept. The only examples I find are always
talk about Web design, I only want to use this data on my
standalone computer. So my question is:

I have a sequential file that contains data and the data is structured.
is there a way to load this data into a DataGrid control?

If the answer is yes, then how do I accomplish this?

I am using vb.net the STANDARD version 2003.

Thanks

Tom
Nov 20 '05 #1
3 1537
Well.. Yes... you can... but coming from a flat file your going to struggle
a little.

In order for databinding to work within windows forms (particularly a grid)
a bindable class must implement ITypedList and IBindingList (for datagrid).
The minimum to do any binding is IList.

So.. the best approach for you is to build a class and derive IList for
starters just to get a feel of how it works (I think IList only has like 3
or 4 members you have to implement) and you can then bind that class. Now
this class will read in your sequential file and expose it to .NET in a
manner they both agree on (the IList Interface), and thats about it.

So.. your class reads in the file and implements IList... so you may have
something.

Public MyReadingClass Implements IList
...implementati on and such
End Class

Public class myForm
inherits System.Windows. Forms.Form

public sub form_load(sende r as object, e as system.eventarg s) handles
mybase.load

dim myReader as new MyReadingClass

myDataGrid.Data Source = myReader
End Sub
End Class

This will give you a basic "list" (no column names, not multiple columns as
far as I know, just a list) but its a starting point for learning interfaces
and understanding IBindingList, and ITypedList.

Thats when it gets really fun (I'm serious, writing custom data binding
classes is fun!)

HTH,
CJ

"Tom McLaughlin" <tb***@cwnet.co m> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I am new to vb.net and I am running into problems understanding
DataBinding and its concept. The only examples I find are always
talk about Web design, I only want to use this data on my
standalone computer. So my question is:

I have a sequential file that contains data and the data is structured.
is there a way to load this data into a DataGrid control?

If the answer is yes, then how do I accomplish this?

I am using vb.net the STANDARD version 2003.

Thanks

Tom

Nov 20 '05 #2
Cor
Hi Tom,

A complete simple sample for your question that I have made a week ago.

The textfile is a csv file which has the comma delimiter in your culture
setting.

I hope this helps?

Cor
\\\drag a datagrid on your form and make a simple textfile
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
path & ";Extended Properties=""Te xt;HDR=No;FMT=D elimited\"""
Dim conn As New OleDb.OleDbConn ection(ConStr)
Dim da As New OleDb.OleDbData Adapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show (ex.ToString)
End Try
DataGrid1.DataS ource = ds.Tables(0)
End Sub
//

I am new to vb.net and I am running into problems understanding
DataBinding and its concept. The only examples I find are always
talk about Web design, I only want to use this data on my
standalone computer. So my question is:

I have a sequential file that contains data and the data is structured.
is there a way to load this data into a DataGrid control?

If the answer is yes, then how do I accomplish this?

I am using vb.net the STANDARD version 2003.

Thanks

Tom

Nov 20 '05 #3
Ahh yes.. of course there is the "easy" way to do it too. =)
"Cor" <no*@non.com> wrote in message
news:Os******** *****@tk2msftng p13.phx.gbl...
Hi Tom,

A complete simple sample for your question that I have made a week ago.

The textfile is a csv file which has the comma delimiter in your culture
setting.

I hope this helps?

Cor
\\\drag a datagrid on your form and make a simple textfile
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
path & ";Extended Properties=""Te xt;HDR=No;FMT=D elimited\"""
Dim conn As New OleDb.OleDbConn ection(ConStr)
Dim da As New OleDb.OleDbData Adapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show (ex.ToString)
End Try
DataGrid1.DataS ource = ds.Tables(0)
End Sub
//

I am new to vb.net and I am running into problems understanding
DataBinding and its concept. The only examples I find are always
talk about Web design, I only want to use this data on my
standalone computer. So my question is:

I have a sequential file that contains data and the data is structured.
is there a way to load this data into a DataGrid control?

If the answer is yes, then how do I accomplish this?

I am using vb.net the STANDARD version 2003.

Thanks

Tom


Nov 20 '05 #4

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

Similar topics

2
2511
by: Paolo Pignatelli | last post by:
I am trying to get an output/file like this (below) in an XML file (MyXmlFile.xml) (which I will use for a slide show) -- <gallery timer="3" order="sequential" fadetime="2" looping="yes" xpos="0" ypos="0"> <image path="images2/Test1.jpg" />
0
3484
by: Jim dunn | last post by:
HI I am having problems with C# with regards to its compatibility with win32 API methods, I am trying to read from a windows CE comm port using C# and imported methods from coredll.dll, it seems that I can set the comm state however when I try and read from the port using ReadFile method I cannot, I've tried to change the DCB object flag types but this does not make a difference as I still cannot read from the port. I have pasted my code...
2
1720
by: Colin Robinson | last post by:
Help please I have an example class called Person with 2 public properties Firstname and Lastname, I cant create a textbox on an asp.net form bound to the Person.Firstname property Can anyone help with the required syntax? if i do TExtbox1.text = x.firstname it works ok, but I want to edit the textbox setting the value of x.firstname.
4
4211
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox), SqlConnection (sqlConnection), SqlDataAdapter (daLookupData), SqlDataAdapter (daData), DataSet (dsLookupData), and DataSet (dsData), all created via the IDE during design-time. Here is the design of my simple tables: (An example since I can't post my...
4
1658
by: Nathan Sokalski | last post by:
I have two databinding expressions (the first & last names from a DB) that I want to assign to the text property of a Label so that the result is LASTNAME,FIRSTNAME. At the moment, I have the following which I know works when I use it by itself: text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname") %>' What I need to do is somehow concatenate this databinding expression, a comma, and another databinding expression for the...
9
2109
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a form, have the user fill it out then put the data into a class representing a data row and then use the OLEadaptor or OLECommands to update the database. My question is has anyone really used databinding in anything but the simpliest application...
8
2186
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
9
2319
by: Nathan Sokalski | last post by:
I have a very simple UserControl which contains an Image and a Label, which I use to display an image with a caption. I am using this control inside a DataList, setting the two Public variables using attributes in the *.aspx page. Everything displays great for the initial load, but whenever I try to add or delete an item (I have controls to do this on the page), it does not seem to be recieving any values for the public variables. Here is...
11
8658
by: Timofmars | last post by:
I'm try to Unload DB2 data from a table into a record sequential file on NT. I can an unload on Mainframe, but it doesn't seem to be an option in NT. In NT, all I can do is export/import. I can do a Load too, but not an Unload. I just want the only the data from the table in a record sequential file. Export seems only to give options to have a delimited line sequential file or a record sequential file where the data is preceeded by...
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10350
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9957
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.