PC Review


Reply
Thread Tools Rate Thread

DataRow - How To?

 
 
MadCrazyNewbie
Guest
Posts: n/a
 
      19th Aug 2004
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 frmMainMenuPasswords_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load

cmDsPasswordList = BindingContext(dsPasswordList, "PasswordList")
mlLoading = True
'Start of Fill Datasets
Try
dsPasswordList.EnforceConstraints = False
dsArcirisUsers.EnforceConstraints = False
Try
Me.odcPasswordLists.Open()
'Fill Password Lists Datasets
Me.odaDepartments.Fill(dsPasswordList)
Me.odaPasswordList.Fill(dsPasswordList)
Catch fillException As System.Exception
Throw fillException
Finally
'To be enabled if Dataset Bindings Fail - Enabling will
cause BIG Datasets
'dsPasswordList.EnforceConstraints = True
Me.odcPasswordLists.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message)
Finally
mlLoading = False
End Try
'End of Fill Datasets
End Sub

'Start of Position Changed Code - Password Lists
Private Sub cmDsPasswordList_PositionChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cmDsPasswordList.PositionChanged
DsPasswordList_PositionChanged()
End Sub

Private Sub cboPasswordListsDepartment_SelectedIndexChanged(ByVal sender
As Object, ByVal e As System.EventArgs) Handles
cboPasswordListsDepartment.SelectedIndexChanged
Me.BindingContext(dsPasswordList, "PasswordList").EndCurrentEdit()
If Me.BindingContext(dsPasswordList, "PasswordList").Position <> -1
And Not mlLoading Then

dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
"PasswordList").Position).Item("DepartmentID") =
Me.cboPasswordListsDepartment.SelectedValue
End If
End Sub

Private Sub DsPasswordList_PositionChanged()
Me.BindingContext(dsPasswordList, "PasswordList").EndCurrentEdit()
If Me.BindingContext(dsPasswordList, "PasswordList").Position <> -1
And Not mlLoading Then
Me.cboPasswordListsDepartment.SelectedValue =
dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
"PasswordList").Position).Item("DepartmentID")
End If
End Sub
'End of Position Changed Code - Password Lists

'PasswordLists Code Start
Private Sub btnPasswordListsDelete_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPasswordListsDelete.Click
If MessageBox.Show("Are Your Sure You Want To Delete?",
"WARNING!!!!", MessageBoxButtons.OKCancel) = DialogResult.OK Then
If (Me.BindingContext(dsPasswordList, "PasswordList").Count > 0)
Then
Me.BindingContext(dsPasswordList,
"PasswordList").RemoveAt(Me.BindingContext(dsPasswordList,
"PasswordList").Position)
End If
End If
End Sub

Private Sub btnPasswordListsAdd_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPasswordListsAdd.Click
'Reset Combo Box`s - Select Index Twice due to M$ Bug
cboPasswordListsDepartment.Text = ""
cboPasswordListsDepartment.SelectedIndex = -1
cboPasswordListsDepartment.SelectedIndex = -1
Try
Me.BindingContext(dsPasswordList,
"PasswordList").EndCurrentEdit()
Me.BindingContext(dsPasswordList, "PasswordList").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
End Sub

Private Sub btnPasswordListsCancel_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPasswordListsCancel.Click
Me.BindingContext(dsPasswordList,
"PasswordList").CancelCurrentEdit()
End Sub

Private Sub btnPasswordListsUpdate_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnPasswordListsUpdate.Click
If MessageBox.Show("Are Your Sure You Want To Save Changes?",
"WARNING!!!!", MessageBoxButtons.OKCancel) = DialogResult.OK Then
Try
Dim objDataSetChanges As Excellence.NET.dsPasswordList = New
Excellence.NET.dsPasswordList()
Me.BindingContext(dsPasswordList,
"PasswordList").EndCurrentEdit()
objDataSetChanges = CType(dsPasswordList.GetChanges,
Excellence.NET.dsPasswordList)
If (Not (objDataSetChanges) Is Nothing) Then
Try
If (Not (dsPasswordList) Is Nothing) Then
Me.odcPasswordLists.Open()
odaDepartments.Update(dsPasswordList)
odaPasswordList.Update(dsPasswordList)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPasswordLists.Close()
End Try
End If
dsPasswordList.Merge(objDataSetChanges)
dsPasswordList.AcceptChanges()
Catch eUpdate As System.Exception
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
End If
End Sub


 
Reply With Quote
 
 
 
 
One Handed Man \( OHM - Terry Burns \)
Guest
Posts: n/a
 
      19th Aug 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 frmMainMenuPasswords_Load(ByVal sender As System.Object, ByVal

e
> As System.EventArgs) Handles MyBase.Load
>
> cmDsPasswordList = BindingContext(dsPasswordList, "PasswordList")
> mlLoading = True
> 'Start of Fill Datasets
> Try
> dsPasswordList.EnforceConstraints = False
> dsArcirisUsers.EnforceConstraints = False
> Try
> Me.odcPasswordLists.Open()
> 'Fill Password Lists Datasets
> Me.odaDepartments.Fill(dsPasswordList)
> Me.odaPasswordList.Fill(dsPasswordList)
> Catch fillException As System.Exception
> Throw fillException
> Finally
> 'To be enabled if Dataset Bindings Fail - Enabling will
> cause BIG Datasets
> 'dsPasswordList.EnforceConstraints = True
> Me.odcPasswordLists.Close()
> End Try
> Catch eLoad As System.Exception
> System.Windows.Forms.MessageBox.Show(eLoad.Message)
> Finally
> mlLoading = False
> End Try
> 'End of Fill Datasets
> End Sub
>
> 'Start of Position Changed Code - Password Lists
> Private Sub cmDsPasswordList_PositionChanged(ByVal sender As Object,
> ByVal e As System.EventArgs) Handles cmDsPasswordList.PositionChanged
> DsPasswordList_PositionChanged()
> End Sub
>
> Private Sub cboPasswordListsDepartment_SelectedIndexChanged(ByVal

sender
> As Object, ByVal e As System.EventArgs) Handles
> cboPasswordListsDepartment.SelectedIndexChanged
> Me.BindingContext(dsPasswordList, "PasswordList").EndCurrentEdit()
> If Me.BindingContext(dsPasswordList, "PasswordList").Position

<> -1
> And Not mlLoading Then
>
> dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
> "PasswordList").Position).Item("DepartmentID") =
> Me.cboPasswordListsDepartment.SelectedValue
> End If
> End Sub
>
> Private Sub DsPasswordList_PositionChanged()
> Me.BindingContext(dsPasswordList, "PasswordList").EndCurrentEdit()
> If Me.BindingContext(dsPasswordList, "PasswordList").Position

<> -1
> And Not mlLoading Then
> Me.cboPasswordListsDepartment.SelectedValue =
> dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
> "PasswordList").Position).Item("DepartmentID")
> End If
> End Sub
> 'End of Position Changed Code - Password Lists
>
> 'PasswordLists Code Start
> Private Sub btnPasswordListsDelete_Click(ByVal sender As

System.Object,
> ByVal e As System.EventArgs) Handles btnPasswordListsDelete.Click
> If MessageBox.Show("Are Your Sure You Want To Delete?",
> "WARNING!!!!", MessageBoxButtons.OKCancel) = DialogResult.OK Then
> If (Me.BindingContext(dsPasswordList, "PasswordList").Count >

0)
> Then
> Me.BindingContext(dsPasswordList,
> "PasswordList").RemoveAt(Me.BindingContext(dsPasswordList,
> "PasswordList").Position)
> End If
> End If
> End Sub
>
> Private Sub btnPasswordListsAdd_Click(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles btnPasswordListsAdd.Click
> 'Reset Combo Box`s - Select Index Twice due to M$ Bug
> cboPasswordListsDepartment.Text = ""
> cboPasswordListsDepartment.SelectedIndex = -1
> cboPasswordListsDepartment.SelectedIndex = -1
> Try
> Me.BindingContext(dsPasswordList,
> "PasswordList").EndCurrentEdit()
> Me.BindingContext(dsPasswordList, "PasswordList").AddNew()
> Catch eEndEdit As System.Exception
> System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
> End Try
> End Sub
>
> Private Sub btnPasswordListsCancel_Click(ByVal sender As

System.Object,
> ByVal e As System.EventArgs) Handles btnPasswordListsCancel.Click
> Me.BindingContext(dsPasswordList,
> "PasswordList").CancelCurrentEdit()
> End Sub
>
> Private Sub btnPasswordListsUpdate_Click(ByVal sender As

System.Object,
> ByVal e As System.EventArgs) Handles btnPasswordListsUpdate.Click
> If MessageBox.Show("Are Your Sure You Want To Save Changes?",
> "WARNING!!!!", MessageBoxButtons.OKCancel) = DialogResult.OK Then
> Try
> Dim objDataSetChanges As Excellence.NET.dsPasswordList =

New
> Excellence.NET.dsPasswordList()
> Me.BindingContext(dsPasswordList,
> "PasswordList").EndCurrentEdit()
> objDataSetChanges = CType(dsPasswordList.GetChanges,
> Excellence.NET.dsPasswordList)
> If (Not (objDataSetChanges) Is Nothing) Then
> Try
> If (Not (dsPasswordList) Is Nothing) Then
> Me.odcPasswordLists.Open()
> odaDepartments.Update(dsPasswordList)
> odaPasswordList.Update(dsPasswordList)
> End If
> Catch updateException As System.Exception
> Throw updateException
> Finally
> Me.odcPasswordLists.Close()
> End Try
> End If
> dsPasswordList.Merge(objDataSetChanges)
> dsPasswordList.AcceptChanges()
> Catch eUpdate As System.Exception
> System.Windows.Forms.MessageBox.Show(eUpdate.Message)
> End Try
> End If
> End Sub
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      19th Aug 2004
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



 
Reply With Quote
 
MadCrazyNewbie
Guest
Posts: n/a
 
      19th Aug 2004
Cor,

On my FaxCopiers form im trying to do:

dvfaxs = New (dsFaxs.Faxs)

is this right? It tell me that D:\Excellence.Net\MainMenuPasswords.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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      19th Aug 2004
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.mytablename

With the dataset you do
dataset11.tables(0)

Cor


 
Reply With Quote
 
MadCrazyNewbie
Guest
Posts: n/a
 
      19th Aug 2004
Cor,

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

Cheers
Si

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.mytablename
>
> With the dataset you do
> dataset11.tables(0)
>
> Cor
>
>



 
Reply With Quote
 
MadCrazyNewbie
Guest
Posts: n/a
 
      19th Aug 2004
Also Cor,

What does:
New DataView(dsPasswordList.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(dsPasswordList.Tables(0)) or

New DataView(dsPasswordList.Departments(0))
New DataView(dsPasswordList.Sites(0))
New DataView(dsPasswordList.User(0)) etc etc

If you get my meaning?

Cheers
MCN

"MadCrazyNewbie" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Cor,
>
> Sorry are you saying name the Datasetname and DatasetDesign name

different?
>
> Cheers
> Si
>
> "Cor Ligthert" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.mytablename
> >
> > With the dataset you do
> > dataset11.tables(0)
> >
> > Cor
> >
> >

>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      19th Aug 2004
Simon,

I get always mixed up with a strongly typed dataset (that is generated from
the dataadapter).

> New DataView(dsPasswordList.Tables(0)) - Mean?


Normal it can be
dim dv as dataview
dv = new dataview(dsPasswordList1.Tables(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





 
Reply With Quote
 
MadCrazyNewbie
Guest
Posts: n/a
 
      19th Aug 2004
Cor,

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

dvPasswordlist = new dataview(dsPasswordList.Tables(0)) or even
dvPasswordlist = new dataview(dsPasswordList1.Tables(0))

I get a error saying : D:\Excellence.Net\MainMenuPasswords.vb(1355): Value
of type 'System.Data.DataView' cannot be converted to '1-dimensional array
of System.Data.DataView'.

Any Ideas?

Cheers
MCN

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Simon,
>
> I get always mixed up with a strongly typed dataset (that is generated

from
> the dataadapter).
>
> > New DataView(dsPasswordList.Tables(0)) - Mean?

>
> Normal it can be
> dim dv as dataview
> dv = new dataview(dsPasswordList1.Tables(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
>
>
>
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      19th Aug 2004
Simon,

I am thinking and thinking and really cannot understand this.

Maybe I get the light tomorrow

Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is DataRow[string] uses DataRow[int] and DataRow[int] much efficient than DataRow[string]? Ryan Liu Microsoft C# .NET 3 2nd Feb 2008 06:14 AM
Distinguish 2 situations when a DataRow in Detached state; Or why not make the data row intact after being added then removed from a dataRow collection? Ryan Liu Microsoft Dot NET 0 7th Jun 2006 03:04 PM
Distinguish 2 situations when a DataRow in Detached state; Or why not make the data row intact after being added then removed from a dataRow collection? Ryan Liu Microsoft C# .NET 0 7th Jun 2006 02:14 AM
create new DataRow, init fields, then set DataRow to UnChanged? Les Caudle Microsoft ADO .NET 2 4th May 2004 05:42 PM
Re: Casting Data.Datarow to a strongly typed datarow CJ Taylor Microsoft VB .NET 4 21st Apr 2004 08:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:54 AM.