473,881 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataRow - How To?

Hey Group,

I wondered if somebody would be so kind as to help me? Im having trouble
with DataViews and DataRows:(

I just don`t understand, so I wondered if somebody would be so kind enought
to modify my code below to include Datarows and Dataviews and maybe explain
a little aswell?

Many Thanks
Regards
MCN
CODE START <<<<


Private Sub frmMainMenuPass words_Load(ByVa l sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load

cmDsPasswordLis t = BindingContext( dsPasswordList, "PasswordLi st")
mlLoading = True
'Start of Fill Datasets
Try
dsPasswordList. EnforceConstrai nts = False
dsArcirisUsers. EnforceConstrai nts = False
Try
Me.odcPasswordL ists.Open()
'Fill Password Lists Datasets
Me.odaDepartmen ts.Fill(dsPassw ordList)
Me.odaPasswordL ist.Fill(dsPass wordList)
Catch fillException As System.Exceptio n
Throw fillException
Finally
'To be enabled if Dataset Bindings Fail - Enabling will
cause BIG Datasets
'dsPasswordList .EnforceConstra ints = True
Me.odcPasswordL ists.Close()
End Try
Catch eLoad As System.Exceptio n
System.Windows. Forms.MessageBo x.Show(eLoad.Me ssage)
Finally
mlLoading = False
End Try
'End of Fill Datasets
End Sub

'Start of Position Changed Code - Password Lists
Private Sub cmDsPasswordLis t_PositionChang ed(ByVal sender As Object,
ByVal e As System.EventArg s) Handles cmDsPasswordLis t.PositionChang ed
DsPasswordList_ PositionChanged ()
End Sub

Private Sub cboPasswordList sDepartment_Sel ectedIndexChang ed(ByVal sender
As Object, ByVal e As System.EventArg s) Handles
cboPasswordList sDepartment.Sel ectedIndexChang ed
Me.BindingConte xt(dsPasswordLi st, "PasswordList") .EndCurrentEdit ()
If Me.BindingConte xt(dsPasswordLi st, "PasswordList") .Position <> -1
And Not mlLoading Then

dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. SelectedValue
End If
End Sub

Private Sub DsPasswordList_ PositionChanged ()
Me.BindingConte xt(dsPasswordLi st, "PasswordList") .EndCurrentEdit ()
If Me.BindingConte xt(dsPasswordLi st, "PasswordList") .Position <> -1
And Not mlLoading Then
Me.cboPasswordL istsDepartment. SelectedValue =
dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" )
End If
End Sub
'End of Position Changed Code - Password Lists

'PasswordLists Code Start
Private Sub btnPasswordList sDelete_Click(B yVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnPasswordList sDelete.Click
If MessageBox.Show ("Are Your Sure You Want To Delete?",
"WARNING!!! !", MessageBoxButto ns.OKCancel) = DialogResult.OK Then
If (Me.BindingCont ext(dsPasswordL ist, "PasswordList") .Count > 0)
Then
Me.BindingConte xt(dsPasswordLi st,
"PasswordList") .RemoveAt(Me.Bi ndingContext(ds PasswordList,
"PasswordList") .Position)
End If
End If
End Sub

Private Sub btnPasswordList sAdd_Click(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles btnPasswordList sAdd.Click
'Reset Combo Box`s - Select Index Twice due to M$ Bug
cboPasswordList sDepartment.Tex t = ""
cboPasswordList sDepartment.Sel ectedIndex = -1
cboPasswordList sDepartment.Sel ectedIndex = -1
Try
Me.BindingConte xt(dsPasswordLi st,
"PasswordList") .EndCurrentEdit ()
Me.BindingConte xt(dsPasswordLi st, "PasswordList") .AddNew()
Catch eEndEdit As System.Exceptio n
System.Windows. Forms.MessageBo x.Show(eEndEdit .Message)
End Try
End Sub

Private Sub btnPasswordList sCancel_Click(B yVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnPasswordList sCancel.Click
Me.BindingConte xt(dsPasswordLi st,
"PasswordList") .CancelCurrentE dit()
End Sub

Private Sub btnPasswordList sUpdate_Click(B yVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnPasswordList sUpdate.Click
If MessageBox.Show ("Are Your Sure You Want To Save Changes?",
"WARNING!!! !", MessageBoxButto ns.OKCancel) = DialogResult.OK Then
Try
Dim objDataSetChang es As Excellence.NET. dsPasswordList = New
Excellence.NET. dsPasswordList( )
Me.BindingConte xt(dsPasswordLi st,
"PasswordList") .EndCurrentEdit ()
objDataSetChang es = CType(dsPasswor dList.GetChange s,
Excellence.NET. dsPasswordList)
If (Not (objDataSetChan ges) Is Nothing) Then
Try
If (Not (dsPasswordList ) Is Nothing) Then
Me.odcPasswordL ists.Open()
odaDepartments. Update(dsPasswo rdList)
odaPasswordList .Update(dsPassw ordList)
End If
Catch updateException As System.Exceptio n
Throw updateException
Finally
Me.odcPasswordL ists.Close()
End Try
End If
dsPasswordList. Merge(objDataSe tChanges)
dsPasswordList. AcceptChanges()
Catch eUpdate As System.Exceptio n
System.Windows. Forms.MessageBo x.Show(eUpdate. Message)
End Try
End If
End Sub
Nov 21 '05 #1
13 1655
There is a plethora of code beneath. I suggest you are more succinct with
you question. What dont you understand about DataRow and DataView.?

Rows isa collection of DataRows in a Table, A tables DataView is a view of
that Table, there is also a DataView class in its own right.

Can you try again now ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"MadCrazyNewbie " <te**@nospam.co m> wrote in message
news:SB******** ************@ka roo.co.uk...
Hey Group,

I wondered if somebody would be so kind as to help me? Im having trouble
with DataViews and DataRows:(

I just don`t understand, so I wondered if somebody would be so kind enought to modify my code below to include Datarows and Dataviews and maybe explain a little aswell?

Many Thanks
Regards
MCN
> CODE START <<<<

Private Sub frmMainMenuPass words_Load(ByVa l sender As System.Object, ByVal

e As System.EventArg s) Handles MyBase.Load

cmDsPasswordLis t = BindingContext( dsPasswordList, "PasswordLi st")
mlLoading = True
'Start of Fill Datasets
Try
dsPasswordList. EnforceConstrai nts = False
dsArcirisUsers. EnforceConstrai nts = False
Try
Me.odcPasswordL ists.Open()
'Fill Password Lists Datasets
Me.odaDepartmen ts.Fill(dsPassw ordList)
Me.odaPasswordL ist.Fill(dsPass wordList)
Catch fillException As System.Exceptio n
Throw fillException
Finally
'To be enabled if Dataset Bindings Fail - Enabling will
cause BIG Datasets
'dsPasswordList .EnforceConstra ints = True
Me.odcPasswordL ists.Close()
End Try
Catch eLoad As System.Exceptio n
System.Windows. Forms.MessageBo x.Show(eLoad.Me ssage)
Finally
mlLoading = False
End Try
'End of Fill Datasets
End Sub

'Start of Position Changed Code - Password Lists
Private Sub cmDsPasswordLis t_PositionChang ed(ByVal sender As Object,
ByVal e As System.EventArg s) Handles cmDsPasswordLis t.PositionChang ed
DsPasswordList_ PositionChanged ()
End Sub

Private Sub cboPasswordList sDepartment_Sel ectedIndexChang ed(ByVal sender As Object, ByVal e As System.EventArg s) Handles
cboPasswordList sDepartment.Sel ectedIndexChang ed
Me.BindingConte xt(dsPasswordLi st, "PasswordList") .EndCurrentEdit ()
If Me.BindingConte xt(dsPasswordLi st, "PasswordList") .Position <> -1 And Not mlLoading Then

dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" ) =
Me.cboPasswordL istsDepartment. SelectedValue
End If
End Sub

Private Sub DsPasswordList_ PositionChanged ()
Me.BindingConte xt(dsPasswordLi st, "PasswordList") .EndCurrentEdit ()
If Me.BindingConte xt(dsPasswordLi st, "PasswordList") .Position <> -1 And Not mlLoading Then
Me.cboPasswordL istsDepartment. SelectedValue =
dsPasswordList. PasswordList.Ro ws(Me.BindingCo ntext(dsPasswor dList,
"PasswordList") .Position).Item ("DepartmentID" )
End If
End Sub
'End of Position Changed Code - Password Lists

'PasswordLists Code Start
Private Sub btnPasswordList sDelete_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnPasswordList sDelete.Click
If MessageBox.Show ("Are Your Sure You Want To Delete?",
"WARNING!!! !", MessageBoxButto ns.OKCancel) = DialogResult.OK Then
If (Me.BindingCont ext(dsPasswordL ist, "PasswordList") .Count > 0) Then
Me.BindingConte xt(dsPasswordLi st,
"PasswordList") .RemoveAt(Me.Bi ndingContext(ds PasswordList,
"PasswordList") .Position)
End If
End If
End Sub

Private Sub btnPasswordList sAdd_Click(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles btnPasswordList sAdd.Click
'Reset Combo Box`s - Select Index Twice due to M$ Bug
cboPasswordList sDepartment.Tex t = ""
cboPasswordList sDepartment.Sel ectedIndex = -1
cboPasswordList sDepartment.Sel ectedIndex = -1
Try
Me.BindingConte xt(dsPasswordLi st,
"PasswordList") .EndCurrentEdit ()
Me.BindingConte xt(dsPasswordLi st, "PasswordList") .AddNew()
Catch eEndEdit As System.Exceptio n
System.Windows. Forms.MessageBo x.Show(eEndEdit .Message)
End Try
End Sub

Private Sub btnPasswordList sCancel_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnPasswordList sCancel.Click
Me.BindingConte xt(dsPasswordLi st,
"PasswordList") .CancelCurrentE dit()
End Sub

Private Sub btnPasswordList sUpdate_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnPasswordList sUpdate.Click
If MessageBox.Show ("Are Your Sure You Want To Save Changes?",
"WARNING!!! !", MessageBoxButto ns.OKCancel) = DialogResult.OK Then
Try
Dim objDataSetChang es As Excellence.NET. dsPasswordList = New Excellence.NET. dsPasswordList( )
Me.BindingConte xt(dsPasswordLi st,
"PasswordList") .EndCurrentEdit ()
objDataSetChang es = CType(dsPasswor dList.GetChange s,
Excellence.NET. dsPasswordList)
If (Not (objDataSetChan ges) Is Nothing) Then
Try
If (Not (dsPasswordList ) Is Nothing) Then
Me.odcPasswordL ists.Open()
odaDepartments. Update(dsPasswo rdList)
odaPasswordList .Update(dsPassw ordList)
End If
Catch updateException As System.Exceptio n
Throw updateException
Finally
Me.odcPasswordL ists.Close()
End Try
End If
dsPasswordList. Merge(objDataSe tChanges)
dsPasswordList. AcceptChanges()
Catch eUpdate As System.Exceptio n
System.Windows. Forms.MessageBo x.Show(eUpdate. Message)
End Try
End If
End Sub

Nov 21 '05 #2
Simon,

It is real hard to answer, however in that "document part" of your
documentation is a very good to see how the dataview is working.

And take some time for it, this is not something done in an hour when you
are not used to it, and even than probably it will take some time.

I suggest that you first have a look at that.

Cor

Nov 21 '05 #3
Cor,

On my FaxCopiers form im trying to do:

dvfaxs = New (dsFaxs.Faxs)

is this right? It tell me that D:\Excellence.N et\MainMenuPass words.vb(1355):
Reference to a non-shared member requires an object reference.

dvfaxs = New Dataview(dsFaxs .tables(0)) it tell me the same

I`ve also tryed:

dvFaxs = New Dataview(dsFaxs .Departments) again the same error.

Could you point me in the right direction?

Cheers
MCN(Si)
"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:O7******** ******@TK2MSFTN GP10.phx.gbl...
Simon,

It is real hard to answer, however in that "document part" of your
documentation is a very good to see how the dataview is working.

And take some time for it, this is not something done in an hour when you
are not used to it, and even than probably it will take some time.

I suggest that you first have a look at that.

Cor

Nov 21 '05 #4
Simon,

I get the idea that you are consequently giving (change) the name of the
actual dataset the same name as the dataset.class that is generated by the
dataadapter.

That makes it difficult to see what you are doing.

You can see that in your dataset properties, give them both a different
name, that will make things easier.

With the class you do
dataset1.mytabl ename

With the dataset you do
dataset11.table s(0)

Cor
Nov 21 '05 #5
Cor,

Sorry are you saying name the Datasetname and DatasetDesign name different?

Cheers
Si

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Simon,

I get the idea that you are consequently giving (change) the name of the
actual dataset the same name as the dataset.class that is generated by the
dataadapter.

That makes it difficult to see what you are doing.

You can see that in your dataset properties, give them both a different
name, that will make things easier.

With the class you do
dataset1.mytabl ename

With the dataset you do
dataset11.table s(0)

Cor

Nov 21 '05 #6
Also Cor,

What does:
New DataView(dsPass wordList.Tables (0)) - Mean?

When im building a Datavies will i mees to build one for each Relationship
or just for the dataset?

Ie - New DataView(dsPass wordList.Tables (0)) or

New DataView(dsPass wordList.Depart ments(0))
New DataView(dsPass wordList.Sites( 0))
New DataView(dsPass wordList.User(0 )) etc etc

If you get my meaning?

Cheers
MCN

"MadCrazyNewbie " <te**@nospam.co m> wrote in message
news:u4******** ************@ka roo.co.uk...
Cor,

Sorry are you saying name the Datasetname and DatasetDesign name different?
Cheers
Si

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Simon,

I get the idea that you are consequently giving (change) the name of the
actual dataset the same name as the dataset.class that is generated by the dataadapter.

That makes it difficult to see what you are doing.

You can see that in your dataset properties, give them both a different
name, that will make things easier.

With the class you do
dataset1.mytabl ename

With the dataset you do
dataset11.table s(0)

Cor


Nov 21 '05 #7
Simon,

I get always mixed up with a strongly typed dataset (that is generated from
the dataadapter).
New DataView(dsPass wordList.Tables (0)) - Mean?


Normal it can be
dim dv as dataview
dv = new dataview(dsPass wordList1.Table s(0))
what mean use for the dv the actual dataset dsPasswordList1 and from that
the first table

A dataview does not make relations. However when you use
dv.rowfilter = "Whatever = WhatIWant"
Then you filter it, what is when you want all the rows in your dataset that
has the ident it gives you all rows that are related to that ident (what you
can see of course as a relation).

When you use a strongly typed dataset you never use that tableindex because
it gives you directly the table.

(A strongly typed dataset is just a name for a class, when you open in your
solution explorere "show all files" you can see them when you open the +
before your datasets.)

I hope this helps sofar?

Cor

Nov 21 '05 #8
Cor,

I think im beginning to understand now, however when i do:

dvPasswordlist = new dataview(dsPass wordList.Tables (0)) or even
dvPasswordlist = new dataview(dsPass wordList1.Table s(0))

I get a error saying : D:\Excellence.N et\MainMenuPass words.vb(1355): Value
of type 'System.Data.Da taView' cannot be converted to '1-dimensional array
of System.Data.Dat aView'.

Any Ideas?

Cheers
MCN

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:uK******** ******@TK2MSFTN GP11.phx.gbl...
Simon,

I get always mixed up with a strongly typed dataset (that is generated from the dataadapter).
New DataView(dsPass wordList.Tables (0)) - Mean?
Normal it can be
dim dv as dataview
dv = new dataview(dsPass wordList1.Table s(0))
what mean use for the dv the actual dataset dsPasswordList1 and from that
the first table

A dataview does not make relations. However when you use
dv.rowfilter = "Whatever = WhatIWant"
Then you filter it, what is when you want all the rows in your dataset

that has the ident it gives you all rows that are related to that ident (what you can see of course as a relation).

When you use a strongly typed dataset you never use that tableindex because it gives you directly the table.

(A strongly typed dataset is just a name for a class, when you open in your solution explorere "show all files" you can see them when you open the +
before your datasets.)

I hope this helps sofar?

Cor


Nov 21 '05 #9
Simon,

I am thinking and thinking and really cannot understand this.

Maybe I get the light tomorrow

Cor
Nov 21 '05 #10

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

Similar topics

1
1878
by: Marcel Sottnik | last post by:
Hello group Maybe this is not the right NG, but this problem seems to me to be more language related than ADO.NET. How can I write the constructor for specialization of DataRow which will take a datarow as parameter. Something like: class MyDataRow : DataRow {
4
2922
by: Michael Carr | last post by:
I have a function that populates a class with values from a database. I'd like to pass into the function either a SqlDataReader or a DataRow, depending on which mechanism I'm using to retrieve data from the database. However, the two classes don't appear to have any common interfaces that would allow me to enumerate the fields. Yet, when you databind you can pass either of these classes (as well as many others) and .NET somehow knows how...
2
1589
by: Steve Amey | last post by:
Hi all I am binding a DataRow to some controls on a form. When I've finished editing the DataRow I click on a toolbar button to save the changes. If the focus is on a particular control, the item in the DataRow does not update to be the value of the control, for example, if I have a TextBox called txtEntry which is bound to the Entry column of the DataRow, if the focus remains on the TextBox while I click on the save button the...
6
1642
by: JIM.H. | last post by:
Hello I have; DataRow dr= dataSet11.myTable.NewRow(); And I am filling the fields of this datarow. Now I need to create a copy of this row as drCopy and change a few fields and add both to the dataset, how can I do this? Thanks,
1
2810
by: Arpan | last post by:
This is how I am dynamically adding a table to a DataSet: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) 'Create an empty DataSet Dim dSet As New DataSet 'Create a new table & add columns Dim dTable As New DataTable("Users") dTable.Columns.Add("ID", Type.GetType("System.Int32"))
5
11724
by: samoore33 | last post by:
I use the code below to search through a DataSet: Dim t As DataTable t = result.Tables("State") Dim strExpr As String strExpr = "id = '" & theState.ToString() & "'" Dim foundRows() As DataRow foundRows = t.Select(strExpr) This of course returns foundRows. My problem is that I need to return
10
24209
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
5
39705
by: Rainer Queck | last post by:
Hello NG, what would be the best way to locate a DataRrow in a DataGridView? I have by DataTable.Select a bunch of DataRows from a DataTable (which is the data source to the DataGridView). Now I would like to give those related DataGridViewRows a different BackColor. Thanks for hints and help! Rainer
2
2017
by: Ryan Liu | last post by:
Is DataRow uses DataRow and DataRow much efficient than DataRow? Thanks, ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. Ryan Liu Shanghai Fengpu Software Co. Ltd Shanghai , China
9
35879
by: myotheraccount | last post by:
Hello, Is there a way to convert a DataRow to a StringArray, without looping through all of the items of the DataRow? Basically, I'm trying to get the results of a query and put them into a listbox. Right now it is done like this:
0
9926
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
9775
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11094
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
10715
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...
1
10811
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7952
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
7105
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();...
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3221
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.