By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,069 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,069 IT Pros & Developers. It's quick & easy.

Data Error

P: n/a
Hey group,

I keep getting the following error:

"An unhandled exception of type 'System.IndexOutOfRangeException' occurred
in system.data.dll
Additional information: There is no row at position 1."

on the following line of code:

Private Sub cboCentrexLinesPrimaryUser_SelectedIndexChanged(By Val sender As
Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesPrimaryUser.SelectedIndexChanged
If Me.BindingContext(dsCentrexLines, "Centrexlines").Position
<> -1 And Not mlLoading Then

dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("UsersID") =
Me.cboCentrexLinesPrimaryUser.SelectedValue
End If
End Sub

Could anybody shed any light as to what this error is or why its happening?

Many Thanks
MCN
Nov 20 '05 #1
Share this Question
Share on Google+
20 Replies


P: n/a
Hi Mad,

This is not knowing, this is guessing.

Can you do a BindingContext(ds.Tables"yourtable").EndCurrentEdi t() before
that row.

Maybe did you create a new row with the BindingContext and is it not yet in
your table.

Just a gues do not shoot when it is wrong

Cor
Nov 20 '05 #2

P: n/a
Sorry Cor, I don`t get what you mean?

I seem to have this problem on all my bindings on all my tables. What code
do I need to put where? Its strange coz it only seems to happen on my
Position_Changed code:(

Many Thanks Again
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
Hi Mad,

This is not knowing, this is guessing.

Can you do a BindingContext(ds.Tables"yourtable").EndCurrentEdi t() before
that row.

Maybe did you create a new row with the BindingContext and is it not yet in your table.

Just a gues do not shoot when it is wrong

Cor

Nov 20 '05 #3

P: n/a
Cor,

I know theres a fair bit but i`ve attached my code incase it might help?
Also any suggestions anybody has would be welcomed for any area of code? im
not sure wether im still classed as a newbie or not now:)

Many Thanks
MCN

Private Sub frmMainMenuPasswords_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
cmDsCentrexLines = BindingContext(dsCentrexLines, "Centrexlines")
cmDsCentrexLines = BindingContext(dsMobiles, "MobilePhones")
cmDsISDNLines = BindingContext(dsISDNLines, "ISDNLines")
cmDsBTLines = BindingContext(dsBTLines, "BTLines")
mlLoading = True
'Start of Fill Datasets
Try
dsCentrexLines.EnforceConstraints = False
Try
Me.odcPhones.Open()
'Fill CentrexLines Copier Datasets
Me.odaCommsType.Fill(dsCentrexLines)
Me.odaSites.Fill(dsCentrexLines)
Me.odaDepartments.Fill(dsCentrexLines)
Me.odaPrimaryUser.Fill(dsCentrexLines)
Me.odaCentrexLines.Fill(dsCentrexLines)
'Fill Mobile Phone Datasets
Me.odaGPRSTarrif.Fill(dsMobiles)
Me.odaDepartments.Fill(dsMobiles)
Me.odaPrimaryUser.Fill(dsMobiles)
Me.odaMobiles.Fill(dsMobiles)
'Fill ISDN Line Datasets
Me.odaSites.Fill(dsISDNLines)
Me.odaDepartments.Fill(dsISDNLines)
Me.odaPrimaryUser.Fill(dsISDNLines)
Me.odaCommsType.Fill(dsISDNLines)
Me.odaCommsCarrier.Fill(dsISDNLines)
Me.odaISDNLines.Fill(dsISDNLines)
'Fill BT Line Datasets
Me.odaSites.Fill(dsBTLines)
Me.odaPrimaryUser.Fill(dsBTLines)
Me.odaCommsType.Fill(dsBTLines)
Me.odaBTLines.Fill(dsBTLines)
Catch fillException As System.Exception
Throw fillException
Finally
'To be enabled if Dataset Bindings Fail - Enabling will
cause BIG Datasets
'dsCentrexLines.EnforceConstraints = True
'dsMobiles.EnforceConstraints = True
'dsISDNLines.EnforceConstraints = True
'dsBTLines.EnforceConstraints = True
Me.odcPhones.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 - Centrexlines
Private Sub cmdsCentrexLines_PositionChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cmDsCentrexLines.PositionChanged
dsCentrexLines_PositionChanged()
End Sub

Private Sub cboCentrexlinesType_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesDepartment.SelectedIndexChanged
If Me.BindingContext(dsCentrexLines, "Centrexlines").Position <> -1
And Not mlLoading Then

dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("CommsTypeID") =
Me.cboCentrexLinesType.SelectedValue
End If
End Sub

Private Sub cboCentrexLinesPrimaryUser_SelectedIndexChanged(By Val sender
As Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesPrimaryUser.SelectedIndexChanged
If Me.BindingContext(dsCentrexLines, "Centrexlines").Position <> -1
And Not mlLoading Then

dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("UsersID") =
Me.cboCentrexLinesPrimaryUser.SelectedValue
End If
End Sub

Private Sub cboCentrexlinesDepartment_SelectedIndexChanged(ByV al sender
As Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesDepartment.SelectedIndexChanged
If Me.BindingContext(dsCentrexLines, "Centrexlines").Position <> -1
And Not mlLoading Then

dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("DepartmentID") =
Me.cboCentrexLinesDepartment.SelectedValue
End If
End Sub

Private Sub cboCentrexLinesite_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesSite.SelectedIndexChanged
If Me.BindingContext(dsCentrexLines, "Centrexlines").Position <> -1
And Not mlLoading Then

dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("SitesID") =
Me.cboCentrexLinesSite.SelectedValue
End If
End Sub

Private Sub dsCentrexLines_PositionChanged()
If Me.BindingContext(dsCentrexLines, "Centrexlines").Position <> -1
Then
Me.cboCentrexLinesType.SelectedValue =
dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("CommsTypeID")
Me.cboCentrexLinesPrimaryUser.SelectedValue =
dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("UsersID")
Me.cboCentrexLinesDepartment.SelectedValue =
dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("DepartmentID")
Me.cboCentrexLinesSite.SelectedValue =
dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("SitesID")
End If
End Sub
'End of Position Changed Code - Centrexlines

'Start of Position Changed Code - Mobile Phones
Private Sub cmdsMobiles_PositionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles cmdsMobilePhones.PositionChanged
dsMobiles_PositionChanged()
End Sub

Private Sub cboMobilePhonesPrimaryUser_SelectedIndexChanged(By Val sender
As Object, ByVal e As System.EventArgs) Handles
cboMobilePhonesPrimaryUser.SelectedIndexChanged
If Me.BindingContext(dsMobiles, "MobilePhones").Position <> -1 And
Not mlLoading Then
dsMobiles.MobilePhones.Rows(Me.BindingContext(dsMo biles,
"MobilePhones").Position).Item("UsersID") =
Me.cboMobilePhonesPrimaryUser.SelectedValue
End If
End Sub

Private Sub cboMobilePhonesDepartment_SelectedIndexChanged(ByV al sender
As Object, ByVal e As System.EventArgs) Handles
cboMobilePhonesDepartment.SelectedIndexChanged
If Me.BindingContext(dsMobiles, "MobilePhones").Position <> -1 And
Not mlLoading Then
dsMobiles.MobilePhones.Rows(Me.BindingContext(dsMo biles,
"MobilePhones").Position).Item("DepartmentID") =
Me.cboMobilePhonesDepartment.SelectedValue
End If
End Sub

Private Sub cboMobilePhoneGPRSTarrif_SelectedIndexChanged(ByVa l sender
As Object, ByVal e As System.EventArgs) Handles
cboMobilePhonesGPRSTariff.SelectedIndexChanged
If Me.BindingContext(dsMobiles, "MobilePhones").Position <> -1 And
Not mlLoading Then
dsMobiles.MobilePhones.Rows(Me.BindingContext(dsMo biles,
"MobilePhones").Position).Item("GPRSTarrifID") =
Me.cboMobilePhonesGPRSTariff.SelectedValue
End If
End Sub

Private Sub dsMobiles_PositionChanged()
If Me.BindingContext(dsMobiles, "MobilePhones").Position <> -1 Then
Me.cboMobilePhonesPrimaryUser.SelectedValue =
dsMobiles.MobilePhones.Rows(Me.BindingContext(dsMo biles,
"MobilePhones").Position).Item("UsersID")
Me.cboMobilePhonesDepartment.SelectedValue =
dsMobiles.MobilePhones.Rows(Me.BindingContext(dsMo biles,
"MobilePhones").Position).Item("DepartmentID")
Me.cboMobilePhonesGPRSTariff.SelectedValue =
dsMobiles.MobilePhones.Rows(Me.BindingContext(dsMo biles,
"MobilePhones").Position).Item("GPRSTariffID")
End If
End Sub
'End of Position Changed Code - Mobile Phones

'Start of Position Changed Code - ISDN Lines
Private Sub cmdsISDNLines_PositionChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles cmDsISDNLines.PositionChanged
dsISDNLines_PositionChanged()
End Sub

Private Sub cboISDNLinesPrimaryUser_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboISDNLinesPrimaryUser.SelectedIndexChanged
If Me.BindingContext(dsISDNLines, "ISDNLines").Position <> -1 And
Not mlLoading Then
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("UsersID") =
Me.cboISDNLinesPrimaryUser.SelectedValue
End If
End Sub

Private Sub cboISDNLinesDepartment_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboISDNLinesDepartment.SelectedIndexChanged
If Me.BindingContext(dsISDNLines, "ISDNLines").Position <> -1 And
Not mlLoading Then
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("DepartmentID") =
Me.cboISDNLinesDepartment.SelectedValue
End If
End Sub

Private Sub cboIDSNLinesType_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboISDNLinesType.SelectedIndexChanged
If Me.BindingContext(dsISDNLines, "ISDNLines").Position <> -1 And
Not mlLoading Then
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("CommsTypeID") =
Me.cboISDNLinesType.SelectedValue
End If
End Sub

Private Sub cboIDSNLinesSite_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboISDNLinesSite.SelectedIndexChanged
If Me.BindingContext(dsISDNLines, "ISDNLines").Position <> -1 And
Not mlLoading Then
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("SitesID") = Me.cboISDNLinesSite.SelectedValue
End If
End Sub

Private Sub cboIDSNLinesCarrier_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboISDNLinesCarrier.SelectedIndexChanged
If Me.BindingContext(dsISDNLines, "ISDNLines").Position <> -1 And
Not mlLoading Then
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("CommsCarrierID") =
Me.cboISDNLinesCarrier.SelectedValue
End If
End Sub

Private Sub dsISDNLines_PositionChanged()
If Me.BindingContext(dsISDNLines, "ISDNLines").Position <> -1 Then
Me.cboISDNLinesPrimaryUser.SelectedValue =
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("UsersID")
Me.cboISDNLinesDepartment.SelectedValue =
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("DepartmentID")
Me.cboISDNLinesCarrier.SelectedValue =
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("LineCarrierID")
Me.cboISDNLinesSite.SelectedValue =
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("SiteID")
Me.cboISDNLinesCarrier.SelectedValue =
dsISDNLines.ISDNLines.Rows(Me.BindingContext(dsISD NLines,
"ISDNLines").Position).Item("CommsCarrierID")
End If
End Sub
'End of Position Changed Code - ISDN Lines

'Start of Position Changed Code - BT Lines
Private Sub cmdsBTLines_PositionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles cmDsBTLines.PositionChanged
dsBTLines_PositionChanged()
End Sub

Private Sub cboBTLinesPrimaryUser_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboBTLinesPrimaryUser.SelectedIndexChanged
If Me.BindingContext(dsBTLines, "BTLines").Position <> -1 And Not
mlLoading Then
dsBTLines.BTLines.Rows(Me.BindingContext(dsBTLines ,
"BTLines").Position).Item("UsersID") =
Me.cboBTLinesPrimaryUser.SelectedValue
End If
End Sub

Private Sub cboBTLinesType_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cboBTLinesType.SelectedIndexChanged
If Me.BindingContext(dsBTLines, "BTLines").Position <> -1 And Not
mlLoading Then
dsBTLines.BTLines.Rows(Me.BindingContext(dsBTLines ,
"BTLines").Position).Item("TypeID") = Me.cboBTLinesType.SelectedValue
End If
End Sub

Private Sub cboBTLinesSite_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cboBTLinesSite.SelectedIndexChanged
If Me.BindingContext(dsBTLines, "BTLines").Position <> -1 And Not
mlLoading Then
dsBTLines.BTLines.Rows(Me.BindingContext(dsBTLines ,
"BTLines").Position).Item("SiteID") = Me.cboBTLinesSite.SelectedValue
End If
End Sub

Private Sub dsBTLines_PositionChanged()
If Me.BindingContext(dsBTLines, "BTLines").Position <> -1 Then
Me.cboBTLinesPrimaryUser.SelectedValue =
dsBTLines.BTLines.Rows(Me.BindingContext(dsBTLines ,
"BTLines").Position).Item("UsersID")
Me.cboBTLinesType.SelectedValue =
dsBTLines.BTLines.Rows(Me.BindingContext(dsBTLines ,
"BTLines").Position).Item("LineCarrierID")
Me.cboBTLinesSite.SelectedValue =
dsBTLines.BTLines.Rows(Me.BindingContext(dsBTLines ,
"BTLines").Position).Item("SiteID")
End If
End Sub
'End of Position Changed Code - BT Lines

'CentrexLines Code Start
Private Sub btnCentrexlinesDelete_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnCentrexLinesDelete.Click
If (Me.BindingContext(dsCentrexLines, "Centrexlines").Count > 0)
Then
Me.BindingContext(dsCentrexLines,
"Centrexlines").RemoveAt(Me.BindingContext(dsCentr exLines,
"Centrexlines").Position)
End If
End Sub

Private Sub btnCentrexlinesAdd_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnCentrexLinesAdd.Click
txtCentrexLinesID.Enabled = True
txtCentrexLinesExtension.Enabled = True
txtCentrexLinesPublicDialNumber.Enabled = True
txtCentrexLinesNotes.Enabled = True
txtCentrexLinesCabNumber.Enabled = True
txtCentrexLinesPatchPoint.Enabled = True
txtCentrexLinesDP.Enabled = True
txtCentrexLinesPair.Enabled = True
txtCentrexLinesExchange.Enabled = True
txtCentrexLinesPatchPanel.Enabled = True
dtpCentrexLinesInstallationDate.Enabled = True
cboCentrexLinesDDI.Enabled = True
cboCentrexLinesType.Enabled = True
cboCentrexLinesDepartment.Enabled = True
cboCentrexLinesSite.Enabled = True
cboCentrexLinesPrimaryUser.Enabled = True
Try
Me.BindingContext(dsCentrexLines,
"Centrexlines").EndCurrentEdit()
Me.BindingContext(dsCentrexLines, "Centrexlines").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Mess age)
End Try
End Sub

Private Sub btnCentrexlinesCancel_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnCentrexLinesCancel.Click
Me.BindingContext(dsCentrexLines,
"Centrexlines").CancelCurrentEdit()
txtCentrexLinesID.Enabled = False
txtCentrexLinesExtension.Enabled = False
txtCentrexLinesPublicDialNumber.Enabled = False
txtCentrexLinesNotes.Enabled = False
txtCentrexLinesCabNumber.Enabled = False
txtCentrexLinesPatchPoint.Enabled = False
txtCentrexLinesDP.Enabled = False
txtCentrexLinesPair.Enabled = False
txtCentrexLinesExchange.Enabled = False
txtCentrexLinesPatchPanel.Enabled = False
dtpCentrexLinesInstallationDate.Enabled = False
cboCentrexLinesDDI.Enabled = False
cboCentrexLinesType.Enabled = False
cboCentrexLinesDepartment.Enabled = False
cboCentrexLinesSite.Enabled = False
cboCentrexLinesPrimaryUser.Enabled = False
End Sub

Private Sub btnCentrexlinesUpdate_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnCentrexLinesUpdate.Click
Try
Dim objDataSetChanges As Excellence.NET.dsCentrexLines = New
Excellence.NET.dsCentrexLines()
Me.BindingContext(dsCentrexLines,
"Centrexlines").EndCurrentEdit()
objDataSetChanges = CType(dsCentrexLines.GetChanges,
Excellence.NET.dsCentrexLines)
If (Not (objDataSetChanges) Is Nothing) Then
Try
If (Not (dsCentrexLines) Is Nothing) Then
Me.odcPhones.Open()
Me.odaCommsType.Fill(dsCentrexLines)
Me.odaSites.Fill(dsCentrexLines)
Me.odaDepartments.Fill(dsCentrexLines)
Me.odaPrimaryUser.Fill(dsCentrexLines)
Me.odaCentrexLines.Fill(dsCentrexLines)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPhones.Close()
End Try
End If
dsCentrexLines.Merge(objDataSetChanges)
dsCentrexLines.AcceptChanges()
Catch eUpdate As System.Exception
System.Windows.Forms.MessageBox.Show(eUpdate.Messa ge)
End Try
txtCentrexLinesID.Enabled = False
txtCentrexLinesExtension.Enabled = False
txtCentrexLinesPublicDialNumber.Enabled = False
txtCentrexLinesNotes.Enabled = False
txtCentrexLinesCabNumber.Enabled = False
txtCentrexLinesPatchPoint.Enabled = False
txtCentrexLinesDP.Enabled = False
txtCentrexLinesPair.Enabled = False
txtCentrexLinesExchange.Enabled = False
txtCentrexLinesPatchPanel.Enabled = False
dtpCentrexLinesInstallationDate.Enabled = False
cboCentrexLinesDDI.Enabled = False
cboCentrexLinesType.Enabled = False
cboCentrexLinesDepartment.Enabled = False
cboCentrexLinesSite.Enabled = False
cboCentrexLinesPrimaryUser.Enabled = False
End Sub

Private Sub btnCentrexlinesEdit_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnCentrexLinesEdit.Click
txtCentrexLinesID.Enabled = True
txtCentrexLinesExtension.Enabled = True
txtCentrexLinesPublicDialNumber.Enabled = True
txtCentrexLinesNotes.Enabled = True
txtCentrexLinesCabNumber.Enabled = True
txtCentrexLinesPatchPoint.Enabled = True
txtCentrexLinesDP.Enabled = True
txtCentrexLinesPair.Enabled = True
txtCentrexLinesExchange.Enabled = True
txtCentrexLinesPatchPanel.Enabled = True
dtpCentrexLinesInstallationDate.Enabled = True
cboCentrexLinesDDI.Enabled = True
cboCentrexLinesType.Enabled = True
cboCentrexLinesDepartment.Enabled = True
cboCentrexLinesSite.Enabled = True
cboCentrexLinesPrimaryUser.Enabled = True
End Sub
'Centrexlines Code Finish

'Mobile Phones Code Start
Private Sub btnMobilePhonesDelete_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnMobilePhonesDelete.Click
If (Me.BindingContext(dsMobiles, "MobilePhones").Count > 0) Then
Me.BindingContext(dsMobiles,
"MobilePhones").RemoveAt(Me.BindingContext(dsMobil es,
"MobilePhones").Position)
End If
End Sub

Private Sub btnMobilePhonesAdd_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnMobilePhonesAdd.Click
txtMobilePhonesID.Enabled = True
txtMobilePhonesMobileNumber.Enabled = True
txtMobilePhonesData.Enabled = True
txtMobilePhonesFax.Enabled = True
txtMobilePhonesSDC.Enabled = True
dtpMobilePhonesContractStartDate.Enabled = True
cboMobilePhonesDepartment.Enabled = True
cboMobilePhonesPrimaryUser.Enabled = True
cboMobilePhonesGPRSTariff.Enabled = True
Try
Me.BindingContext(dsMobiles, "MobilePhones").EndCurrentEdit()
Me.BindingContext(dsMobiles, "MobilePhones").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Mess age)
End Try
End Sub

Private Sub btnMobilePhonesCancel_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnMobilePhonesCancel.Click
Me.BindingContext(dsMobiles, "MobilePhones").CancelCurrentEdit()
txtMobilePhonesID.Enabled = False
txtMobilePhonesMobileNumber.Enabled = False
txtMobilePhonesData.Enabled = False
txtMobilePhonesFax.Enabled = False
txtMobilePhonesSDC.Enabled = False
dtpMobilePhonesContractStartDate.Enabled = False
cboMobilePhonesDepartment.Enabled = False
cboMobilePhonesPrimaryUser.Enabled = False
cboMobilePhonesGPRSTariff.Enabled = False
End Sub

Private Sub btnMobilePhonesUpdate_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnMobilePhonesUpdate.Click
Try
Dim objDataSetChanges As Excellence.NET.dsMobiles = New
Excellence.NET.dsMobiles()
Me.BindingContext(dsMobiles, "MobilePhones").EndCurrentEdit()
objDataSetChanges = CType(dsMobiles.GetChanges,
Excellence.NET.dsMobiles)
If (Not (objDataSetChanges) Is Nothing) Then
Try
If (Not (dsMobiles) Is Nothing) Then
Me.odcPhones.Open()
Me.odaDepartments.Fill(dsMobiles)
Me.odaPrimaryUser.Fill(dsMobiles)
Me.odaGPRSTarrif.Fill(dsMobiles)
Me.odaMobiles.Fill(dsMobiles)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPhones.Close()
End Try
End If
dsMobiles.Merge(objDataSetChanges)
dsMobiles.AcceptChanges()
Catch eUpdate As System.Exception
System.Windows.Forms.MessageBox.Show(eUpdate.Messa ge)
End Try
txtMobilePhonesID.Enabled = False
txtMobilePhonesMobileNumber.Enabled = False
txtMobilePhonesData.Enabled = False
txtMobilePhonesFax.Enabled = False
txtMobilePhonesSDC.Enabled = False
dtpMobilePhonesContractStartDate.Enabled = False
cboMobilePhonesDepartment.Enabled = False
cboMobilePhonesPrimaryUser.Enabled = False
cboMobilePhonesGPRSTariff.Enabled = False
End Sub

Private Sub btnMobilePhonesEdit_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnMobilePhonesEdit.Click
txtMobilePhonesID.Enabled = True
txtMobilePhonesMobileNumber.Enabled = True
txtMobilePhonesData.Enabled = True
txtMobilePhonesFax.Enabled = True
txtMobilePhonesSDC.Enabled = True
dtpMobilePhonesContractStartDate.Enabled = True
cboMobilePhonesDepartment.Enabled = True
cboMobilePhonesPrimaryUser.Enabled = True
cboMobilePhonesGPRSTariff.Enabled = True
End Sub
'Mobile Phones Code Finish

'ISDN Lines Code Start
Private Sub btnISDNLinesDelete_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnISDNLinesDelete.Click
If (Me.BindingContext(dsISDNLines, "ISDNLines").Count > 0) Then
Me.BindingContext(dsISDNLines,
"ISDNLines").RemoveAt(Me.BindingContext(dsISDNLine s, "ISDNLines").Position)
End If
End Sub

Private Sub btnISDNLinesAdd_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnISDNLinesAdd.Click
txtISDNLinesID.Enabled = True
txtISDNLinesPrimaryNumber.Enabled = True
txtISDNLinesSecondaryNumber.Enabled = True
txtISDNLinesNotes.Enabled = True
txtISDNLinesCab.Enabled = True
txtISDNLinesPatch.Enabled = True
txtISDNLinesPoint.Enabled = True
txtISDNLinesDP.Enabled = True
txtISDNLinesPair.Enabled = True
txtISDNLinesExchange.Enabled = True
cboISDNLinesPrimaryUser.Enabled = True
cboISDNLinesDepartment.Enabled = True
cboISDNLinesType.Enabled = True
cboISDNLinesCarrier.Enabled = True
cboISDNLinesSite.Enabled = True
dtpISDNLinesInstallationDate.Enabled = True
Try
Me.BindingContext(dsISDNLines, "ISDNLines").EndCurrentEdit()
Me.BindingContext(dsISDNLines, "ISDNLines").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Mess age)
End Try
End Sub

Private Sub btnISDNLinesCancel_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnISDNLinesCancel.Click
Me.BindingContext(dsISDNLines, "ISDNLines").CancelCurrentEdit()
txtISDNLinesID.Enabled = False
txtISDNLinesPrimaryNumber.Enabled = False
txtISDNLinesSecondaryNumber.Enabled = False
txtISDNLinesNotes.Enabled = False
txtISDNLinesCab.Enabled = False
txtISDNLinesPatch.Enabled = False
txtISDNLinesPoint.Enabled = False
txtISDNLinesDP.Enabled = False
txtISDNLinesPair.Enabled = False
txtISDNLinesExchange.Enabled = False
cboISDNLinesPrimaryUser.Enabled = False
cboISDNLinesDepartment.Enabled = False
cboISDNLinesType.Enabled = False
cboISDNLinesCarrier.Enabled = False
cboISDNLinesSite.Enabled = False
dtpISDNLinesInstallationDate.Enabled = False
End Sub

Private Sub btnISDNLinesUpdate_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnISDNLinesUpdate.Click
Try
Dim objDataSetChanges As Excellence.NET.dsISDNLines = New
Excellence.NET.dsISDNLines()
Me.BindingContext(dsISDNLines, "ISDNLines").EndCurrentEdit()
objDataSetChanges = CType(dsISDNLines.GetChanges,
Excellence.NET.dsISDNLines)
If (Not (objDataSetChanges) Is Nothing) Then
Try
If (Not (dsISDNLines) Is Nothing) Then
Me.odcPhones.Open()
Me.odaDepartments.Fill(dsISDNLines)
Me.odaCommsType.Fill(dsISDNLines)
Me.odaDepartments.Fill(dsISDNLines)
Me.odaPrimaryUser.Fill(dsISDNLines)
Me.odaCommsCarrier.Fill(dsISDNLines)
Me.odaISDNLines.Fill(dsISDNLines)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPhones.Close()
End Try
End If
dsISDNLines.Merge(objDataSetChanges)
dsISDNLines.AcceptChanges()
Catch eUpdate As System.Exception
System.Windows.Forms.MessageBox.Show(eUpdate.Messa ge)
End Try
txtISDNLinesID.Enabled = False
txtISDNLinesPrimaryNumber.Enabled = False
txtISDNLinesSecondaryNumber.Enabled = False
txtISDNLinesNotes.Enabled = False
txtISDNLinesCab.Enabled = False
txtISDNLinesPatch.Enabled = False
txtISDNLinesPoint.Enabled = False
txtISDNLinesDP.Enabled = False
txtISDNLinesPair.Enabled = False
txtISDNLinesExchange.Enabled = False
cboISDNLinesPrimaryUser.Enabled = False
cboISDNLinesDepartment.Enabled = False
cboISDNLinesType.Enabled = False
cboISDNLinesCarrier.Enabled = False
cboISDNLinesSite.Enabled = False
dtpISDNLinesInstallationDate.Enabled = False
End Sub

Private Sub btnISDNLinesEdit_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnISDNLinesEdit.Click
txtISDNLinesID.Enabled = True
txtISDNLinesPrimaryNumber.Enabled = True
txtISDNLinesSecondaryNumber.Enabled = True
txtISDNLinesNotes.Enabled = True
txtISDNLinesCab.Enabled = True
txtISDNLinesPatch.Enabled = True
txtISDNLinesPoint.Enabled = True
txtISDNLinesDP.Enabled = True
txtISDNLinesPair.Enabled = True
txtISDNLinesExchange.Enabled = True
cboISDNLinesPrimaryUser.Enabled = True
cboISDNLinesDepartment.Enabled = True
cboISDNLinesType.Enabled = True
cboISDNLinesCarrier.Enabled = True
cboISDNLinesSite.Enabled = True
dtpISDNLinesInstallationDate.Enabled = True
End Sub
'ISDN Lines Code Finish

'BT Lines Code Start
Private Sub btnBTLinesDelete_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnBTLinesDelete.Click
If (Me.BindingContext(dsBTLines, "BTLines").Count > 0) Then
Me.BindingContext(dsBTLines,
"BTLines").RemoveAt(Me.BindingContext(dsBTLine s, "BTLines").Position)
End If
End Sub

Private Sub btnBTLinesAdd_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnBTLinesAdd.Click
txtBTLinesID.Enabled = True
txtBTLinesNumber.Enabled = True
txtBTLinesAccountNumber.Enabled = True
txtBTLinesNotes.Enabled = True
txtBTLinesDP.Enabled = True
txtBTLinesPair.Enabled = True
txtBTLinesExchange.Enabled = True
cboBTLinesPrimaryUser.Enabled = True
cboBTLinesType.Enabled = True
cboBTLinesSite.Enabled = True
dtpBTLinesInstallationDate.Enabled = True
Try
Me.BindingContext(dsBTLines, "BTLines").EndCurrentEdit()
Me.BindingContext(dsBTLines, "BTLines").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Mess age)
End Try
End Sub

Private Sub btnBTLinesCancel_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnBTLinesCancel.Click
Me.BindingContext(dsBTLines, "BTLines").CancelCurrentEdit()
txtBTLinesID.Enabled = False
txtBTLinesNumber.Enabled = False
txtBTLinesAccountNumber.Enabled = False
txtBTLinesNotes.Enabled = False
txtBTLinesDP.Enabled = False
txtBTLinesPair.Enabled = False
txtBTLinesExchange.Enabled = False
cboBTLinesPrimaryUser.Enabled = False
cboBTLinesType.Enabled = False
cboBTLinesSite.Enabled = False
dtpBTLinesInstallationDate.Enabled = False
End Sub

Private Sub btnBTLinesUpdate_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnBTLinesUpdate.Click
Try
Dim objDataSetChanges As Excellence.NET.dsBTLines = New
Excellence.NET.dsBTLines()
Me.BindingContext(dsBTLines, "BTLines").EndCurrentEdit()
objDataSetChanges = CType(dsBTLines.GetChanges,
Excellence.NET.dsBTLines)
If (Not (objDataSetChanges) Is Nothing) Then
Try
If (Not (dsBTLines) Is Nothing) Then
Me.odcPhones.Open()
Me.odaSites.Fill(dsBTLines)
Me.odaPrimaryUser.Fill(dsBTLines)
Me.odaCommsType.Fill(dsBTLines)
Me.odaBTLines.Fill(dsBTLines)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPhones.Close()
End Try
End If
dsBTLines.Merge(objDataSetChanges)
dsBTLines.AcceptChanges()
Catch eUpdate As System.Exception
System.Windows.Forms.MessageBox.Show(eUpdate.Messa ge)
End Try
txtBTLinesID.Enabled = False
txtBTLinesNumber.Enabled = False
txtBTLinesAccountNumber.Enabled = False
txtBTLinesNotes.Enabled = False
txtBTLinesDP.Enabled = False
txtBTLinesPair.Enabled = False
txtBTLinesExchange.Enabled = False
cboBTLinesPrimaryUser.Enabled = False
cboBTLinesType.Enabled = False
cboBTLinesSite.Enabled = False
dtpBTLinesInstallationDate.Enabled = True
End Sub

Private Sub btnBTLinesEdit_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnBTLinesEdit.Click
txtBTLinesID.Enabled = True
txtBTLinesNumber.Enabled = True
txtBTLinesAccountNumber.Enabled = True
txtBTLinesNotes.Enabled = True
txtBTLinesDP.Enabled = True
txtBTLinesPair.Enabled = True
txtBTLinesExchange.Enabled = True
cboBTLinesPrimaryUser.Enabled = True
cboBTLinesType.Enabled = True
cboBTLinesSite.Enabled = True
dtpBTLinesInstallationDate.Enabled = True
End Sub
'BT Lines Code Finish

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
Hi Mad,

This is not knowing, this is guessing.

Can you do a BindingContext(ds.Tables"yourtable").EndCurrentEdi t() before
that row.

Maybe did you create a new row with the BindingContext and is it not yet in your table.

Just a gues do not shoot when it is wrong

Cor

Nov 20 '05 #4

P: n/a
Hi Mad,

I have seen what I think that gives the error, however I have also seen
things in this code what is in my opinion wrong. However not more tonight,
when I do not see that everything is resolved I do it tomorrow.

And when it is keep watching this thread because I have seen an error which
is in my opinion more made, I will try to check it tomorrow.

Cor
Nov 20 '05 #5

P: n/a
Hi Mad,

I have looked at your code, it is to much to do everything and I do not have
the database and the controls, creating that is real to much work.

However I did look deep to it, there are errors in it however I cannot see
how that reflects to your errors.

First advice set on Option Strict

I saw in the first 3 rows something that should give an error. See what I
changed (not only syntatical, you use the wrong name for the currencymanager
in my opinion in your program)
\\\
Dim cmDScentrexLines As CurrencyManager
Dim cmDSMobiles As CurrencyManager
Private Sub frmMainMenuPasswords_Load(ByVal _
sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
cmDScentrexLines = DirectCast(BindingContext(dsCentrexLines, _
"Centrexlines"), CurrencyManager)
cmDSMobiles = DirectCast(BindingContext(dsMobiles, _
"MobilePhones"), CurrencyManager)
////
Then it is easier for debugging when you have an error to break up commands,
when it is working you can alway set it back to some more compact code.

I tried it to change as far as I could understand what you did want to do,
and as I said, I could not test anything.

\\\\
Private Sub cboCentrexlinesType_SelectedIndexChanged(ByVal sender As
Object, _
ByVal e As System.EventArgs) Handles
cboCentrexLinesDepartment.SelectedIndexChanged
If cmDScentrexLines.Position <> -1 And _
Not mlLoading Then
Dim i As Integer = cmDScentrexLines.Position
dsCentrexLines.CentrexLines.Rows(i).Item("CommsTyp eID") = _
Me.cboCentrexLinesType.SelectedValue()
End If
End Sub
///

Then I have seen you use the "remove", what it does is deleting rows from a
datarow, however does not update that remove in the dataset, for that you
have to use the "delete" (there is no rowstate "remove").

It is mostly difficult to find that delete if you do not know it, when you
know it is again easy, here a link with some samples, but that is not the
only method.

http://support.microsoft.com/default...b;en-us;301248

///

What I am curious for is what is the value from that *i* when the error is
thrown.

I hope this helps so far?

Cor
Nov 20 '05 #6

P: n/a
Cor,

Many thanks for your reply, i`ll have a look and start changing my code
around. I`ll post here in a while and let you know what happens

Many thanks
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
Hi Mad,

I have looked at your code, it is to much to do everything and I do not have the database and the controls, creating that is real to much work.

However I did look deep to it, there are errors in it however I cannot see
how that reflects to your errors.

First advice set on Option Strict

I saw in the first 3 rows something that should give an error. See what I
changed (not only syntatical, you use the wrong name for the currencymanager in my opinion in your program)
\\\
Dim cmDScentrexLines As CurrencyManager
Dim cmDSMobiles As CurrencyManager
Private Sub frmMainMenuPasswords_Load(ByVal _
sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
cmDScentrexLines = DirectCast(BindingContext(dsCentrexLines, _
"Centrexlines"), CurrencyManager)
cmDSMobiles = DirectCast(BindingContext(dsMobiles, _
"MobilePhones"), CurrencyManager)
////
Then it is easier for debugging when you have an error to break up commands, when it is working you can alway set it back to some more compact code.

I tried it to change as far as I could understand what you did want to do,
and as I said, I could not test anything.

\\\\
Private Sub cboCentrexlinesType_SelectedIndexChanged(ByVal sender As
Object, _
ByVal e As System.EventArgs) Handles
cboCentrexLinesDepartment.SelectedIndexChanged
If cmDScentrexLines.Position <> -1 And _
Not mlLoading Then
Dim i As Integer = cmDScentrexLines.Position
dsCentrexLines.CentrexLines.Rows(i).Item("CommsTyp eID") = _
Me.cboCentrexLinesType.SelectedValue()
End If
End Sub
///

Then I have seen you use the "remove", what it does is deleting rows from a datarow, however does not update that remove in the dataset, for that you
have to use the "delete" (there is no rowstate "remove").

It is mostly difficult to find that delete if you do not know it, when you
know it is again easy, here a link with some samples, but that is not the
only method.

http://support.microsoft.com/default...b;en-us;301248

///

What I am curious for is what is the value from that *i* when the error is
thrown.

I hope this helps so far?

Cor

Nov 20 '05 #7

P: n/a
Cor,

I`ve made the following changes to my programs, as below. I`ve also cut out
a lot to make it simple and only one form.

When i run it and try and select a option from my combo box it just fails
again say "No Position at Row 1" and errors on this line:

dsCentrexLines.CentrexLines.Rows(I).Item("UsersID" ) =
Me.cboCentrexLinesPrimaryUser.SelectedValue (or the corosponding line from
the Position_Changed for that Combo Box)

Cor, one thing does it matter the order of the Postion_Changed items, like
it does when you fill the Datasets?

Many Thanks Again
MCN

Cor - Here is my new code

Private Sub frmMainMenuPhones_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
cmDsCentrexLines = DirectCast(BindingContext(dsCentrexLines,
"Centrexlines"), CurrencyManager)
mlLoading = True
'Start of Fill Datasets
Try
dsCentrexLines.EnforceConstraints = False
Try
Me.odcPhones.Open()
'Fill CentrexLines Copier Datasets
Me.odaCommsType.Fill(dsCentrexLines)
Me.odaSites.Fill(dsCentrexLines)
Me.odaDepartments.Fill(dsCentrexLines)
Me.odaPrimaryUser.Fill(dsCentrexLines)
Me.odaCentrexLines.Fill(dsCentrexLines)
Catch fillException As System.Exception
Throw fillException
Finally
'To be enabled if Dataset Bindings Fail - Enabling will
cause BIG Datasets
'dsCentrexLines.EnforceConstraints = True
Me.odcPhones.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 - Centrexlines
Private Sub cmdsCentrexLines_PositionChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cmDsCentrexLines.PositionChanged
dsCentrexLines_PositionChanged()
End Sub

Private Sub cboCentrexLinesType_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesDepartment.SelectedIndexChanged
If cmDsCentrexLines.Position <> -1 And Not mlLoading Then
Dim I As Integer = cmDsCentrexLines.Position
dsCentrexLines.CentrexLines.Rows(I).Item("CommsTyp eID") =
Me.cboCentrexLinesType.SelectedValue
End If
End Sub

Private Sub cboCentrexLinesPrimaryUser_SelectedIndexChanged(By Val sender
As Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesPrimaryUser.SelectedIndexChanged
If cmDsCentrexLines.Position <> -1 And Not mlLoading Then
Dim I As Integer = cmDsCentrexLines.Position
dsCentrexLines.CentrexLines.Rows(I).Item("UsersID" ) =
Me.cboCentrexLinesPrimaryUser.SelectedValue
End If
End Sub

Private Sub cboCentrexlinesDepartment_SelectedIndexChanged(ByV al sender
As Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesDepartment.SelectedIndexChanged
If cmDsCentrexLines.Position <> -1 And Not mlLoading Then
Dim I As Integer = cmDsCentrexLines.Position
dsCentrexLines.CentrexLines.Rows(I).Item("Departme ntID") =
Me.cboCentrexLinesDepartment.SelectedValue
End If
End Sub

Private Sub cboCentrexLinesSite_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesSite.SelectedIndexChanged
If cmDsCentrexLines.Position <> -1 And Not mlLoading Then
Dim I As Integer = cmDsCentrexLines.Position
dsCentrexLines.CentrexLines.Rows(I).Item("SitesID" ) =
Me.cboCentrexLinesSite.SelectedValue
End If
End Sub

Private Sub dsCentrexLines_PositionChanged()
If Me.BindingContext(dsCentrexLines, "Centrexlines").Position <> -1
Then
Me.cboCentrexLinesType.SelectedValue =
dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("CommsTypeID")
Me.cboCentrexLinesPrimaryUser.SelectedValue =
dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("UsersID")
Me.cboCentrexLinesDepartment.SelectedValue =
dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("DepartmentID")
Me.cboCentrexLinesSite.SelectedValue =
dsCentrexLines.CentrexLines.Rows(Me.BindingContext (dsCentrexLines,
"Centrexlines").Position).Item("SitesID")
End If
End Sub
'END of Position Changed Code - Centrexlines

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:M5********************@karoo.co.uk...
Cor,

Many thanks for your reply, i`ll have a look and start changing my code
around. I`ll post here in a while and let you know what happens

Many thanks
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
Hi Mad,

I have looked at your code, it is to much to do everything and I do not have
the database and the controls, creating that is real to much work.

However I did look deep to it, there are errors in it however I cannot see how that reflects to your errors.

First advice set on Option Strict

I saw in the first 3 rows something that should give an error. See what I changed (not only syntatical, you use the wrong name for the

currencymanager
in my opinion in your program)
\\\
Dim cmDScentrexLines As CurrencyManager
Dim cmDSMobiles As CurrencyManager
Private Sub frmMainMenuPasswords_Load(ByVal _
sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
cmDScentrexLines = DirectCast(BindingContext(dsCentrexLines, _
"Centrexlines"), CurrencyManager)
cmDSMobiles = DirectCast(BindingContext(dsMobiles, _
"MobilePhones"), CurrencyManager)
////
Then it is easier for debugging when you have an error to break up

commands,
when it is working you can alway set it back to some more compact code.

I tried it to change as far as I could understand what you did want to do, and as I said, I could not test anything.

\\\\
Private Sub cboCentrexlinesType_SelectedIndexChanged(ByVal sender As
Object, _
ByVal e As System.EventArgs) Handles
cboCentrexLinesDepartment.SelectedIndexChanged
If cmDScentrexLines.Position <> -1 And _
Not mlLoading Then
Dim i As Integer = cmDScentrexLines.Position
dsCentrexLines.CentrexLines.Rows(i).Item("CommsTyp eID") = _
Me.cboCentrexLinesType.SelectedValue()
End If
End Sub
///

Then I have seen you use the "remove", what it does is deleting rows from a
datarow, however does not update that remove in the dataset, for that

you have to use the "delete" (there is no rowstate "remove").

It is mostly difficult to find that delete if you do not know it, when you know it is again easy, here a link with some samples, but that is not the only method.

http://support.microsoft.com/default...b;en-us;301248

///

What I am curious for is what is the value from that *i* when the error is thrown.

I hope this helps so far?

Cor


Nov 20 '05 #8

P: n/a
Hi Mad,

You know I am myself also fighting with the combobox however that is the
textbox part.

Can you try this and tell what it is?

\\\
Private Sub cboCentrexLinesPrimaryUser_SelectedIndexChanged(By Val sender As Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesPrimaryUser.SelectedIndexChanged
If cmDsCentrexLines.Position <> -1 And Not mlLoading Then
Dim I As Integer = cmDsCentrexLines.Position Dim y as integer = dsCentrexLines.CentrexLines.Rows.count

messagebox.show(I.tostring & " " & Y.tostring)

Position is a zero index so the count should always be one more than the
position.
dsCentrexLines.CentrexLines.Rows(I).Item("UsersID" ) =
Me.cboCentrexLinesPrimaryUser.SelectedValue
End If
End Sub


Nov 20 '05 #9

P: n/a
Hey cor,

Using the following Code:-

Private Sub cboCentrexLinesPrimaryUser_SelectedIndexChanged(By Val sender As
Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesPrimaryUser.SelectedIndexChanged
If cmDsCentrexLines.Position <> -1 And Not mlLoading Then
Dim I As Integer = cmDsCentrexLines.Position
Dim y As Integer = dsCentrexLines.CentrexLines.Rows.Count
MessageBox.Show(I.ToString & " " & y.ToString)
dsCentrexLines.CentrexLines.Rows(I).Item("UsersID" ) =
Me.cboCentrexLinesPrimaryUser.SelectedValue
End If
End Sub

When i first run my App it pops up and tells me 0 1, when i select something
from my ComboBox it tells me 1 1 , then fails again on the same code:(

Many Thanks
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
Hi Mad,

You know I am myself also fighting with the combobox however that is the
textbox part.

Can you try this and tell what it is?

\\\
> Private Sub cboCentrexLinesPrimaryUser_SelectedIndexChanged(By Val

sender
As Object, ByVal e As System.EventArgs) Handles
cboCentrexLinesPrimaryUser.SelectedIndexChanged
If cmDsCentrexLines.Position <> -1 And Not mlLoading Then
Dim I As Integer = cmDsCentrexLines.Position

Dim y as integer = dsCentrexLines.CentrexLines.Rows.count

messagebox.show(I.tostring & " " & Y.tostring)

Position is a zero index so the count should always be one more than the
position.
dsCentrexLines.CentrexLines.Rows(I).Item("UsersID" ) =
Me.cboCentrexLinesPrimaryUser.SelectedValue
End If
End Sub


Nov 20 '05 #10

P: n/a
Hi Mad,

It should fail.

It says that there is one datarow in your datatable while your position is
on the second row (1 with 0 index is second).

What is your select, is there standard always one row, than you do not need
that position, you just can put there a 0.

Cor
Nov 20 '05 #11

P: n/a
Hi Cor,

Many thanks again for you help,

My Select Statements are very simple, Select * From CentrexLines, for
example.

I wonder if you could explain something for me? In the below code what is
the Postition -1 used for i know its the position but when would you -1, 0,
or 1?

Private Sub cboBTLinesSite_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cboBTLinesSite.SelectedIndexChanged
If Me.BindingContext(dsBTLines, "BTLines").Position <> 1 And Not
mlLoading Then
dsBTLines.BTLines.Rows(Me.BindingContext(dsBTLines ,
"BTLines").Position).Item("SitesID") = Me.cboBTLinesSite.SelectedValue
End If
End Sub

Also I have changed on all my code the -1`s to 1`s and it works great now,
only on the code below comes up with an error saying:

An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll

Additional information: System.InvalidCastException: Specified cast is not
valid.
at System.Convert.ToInt32(Object value)
at System.Data.Common.Int32Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't
store <System.Data.DataRowView> in SitesID Column. Expected type is Int32.

Any Ideas?

Many Thanks
MCN
Nov 20 '05 #12

P: n/a
Hi Mad,

Problem is that this part of the code should not be needed.
I think you have set the datasource for the comboboxes in the designer.
When you bind than the selectedItem to the table it should work.
(And now we are in the part from the combobox I cannot get my hands on and
have also problems with)

cmoBTLinesSite.DataBindings.Add(New Binding("SelectedValue",
dsBTLines("BTLines"), "ident"))

This can also be done in the designer, and than should the indexed change
event not be needed anymore

Can you try if that does someting for you (the binding has to be done only
one time or try the designer at the datasource)

It works for me, however I have effects I do not understand (and I want to
use the Text property, from that selectedvalue I have the idea that it
works).
Private Sub cboBTLinesSite_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cboBTLinesSite.SelectedIndexChanged
If Me.BindingContext(dsBTLines, "BTLines").Position <> 1 And Not
mlLoading Then
dsBTLines.BTLines.Rows(Me.BindingContext(dsBTLines ,
"BTLines").Position).Item("SitesID") = Me.cboBTLinesSite.SelectedValue
End If
End Sub

Nov 20 '05 #13

P: n/a
Cor,

Sorry I don`t understand where I need to put this? Could you explain a
little more please?

Also my Update code isn`t working now, it updates in my Dataset (Because it
updates my Datagrid) but if i re-load my Ds after a Update the data Has
gone:(

Here is my Update code:

Private Sub btnCentrexLinesUpdate_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnCentrexLinesUpdate.Click
Try
Dim objDataSetChanges As Excellence.NET.dsCentrexLines = New
Excellence.NET.dsCentrexLines()
Me.BindingContext(dsCentrexLines, "Centrexlines").EndCurrentEdit()
objDataSetChanges = CType(dsCentrexLines.GetChanges,
Excellence.NET.dsCentrexLines)
If (Not (objDataSetChanges) Is Nothing) Then
Try
If (Not (dsCentrexLines) Is Nothing) Then
Me.odcPhones.Open()
Me.odaCommsType.Fill(dsCentrexLines)
Me.odaSites.Fill(dsCentrexLines)
Me.odaDepartments.Fill(dsCentrexLines)
Me.odaPrimaryUser.Fill(dsCentrexLines)
Me.odaCentrexLines.Fill(dsCentrexLines)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPhones.Close()
End Try
End If
dsCentrexLines.Merge(objDataSetChanges)
dsCentrexLines.AcceptChanges()
Catch eUpdate As System.Exception
System.Windows.Forms.MessageBox.Show(eUpdate.Messa ge)
End Try
txtCentrexLinesID.Enabled = False
txtCentrexLinesExtension.Enabled = False
txtCentrexLinesPublicDialNumber.Enabled = False
txtCentrexLinesNotes.Enabled = False
txtCentrexLinesCabNumber.Enabled = False
txtCentrexLinesPatchPoint.Enabled = False
txtCentrexLinesDP.Enabled = False
txtCentrexLinesPair.Enabled = False
txtCentrexLinesExchange.Enabled = False
txtCentrexLinesPatchPanel.Enabled = False
dtpCentrexLinesInstallationDate.Enabled = False
cboCentrexLinesDDI.Enabled = False
cboCentrexLinesType.Enabled = False
cboCentrexLinesDepartment.Enabled = False
cboCentrexLinesSite.Enabled = False
cboCentrexLinesPrimaryUser.Enabled = False

Ta
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ev****************@TK2MSFTNGP12.phx.gbl...
Hi Mad,

Problem is that this part of the code should not be needed.
I think you have set the datasource for the comboboxes in the designer.
When you bind than the selectedItem to the table it should work.
(And now we are in the part from the combobox I cannot get my hands on and
have also problems with)

cmoBTLinesSite.DataBindings.Add(New Binding("SelectedValue",
dsBTLines("BTLines"), "ident"))

This can also be done in the designer, and than should the indexed change
event not be needed anymore

Can you try if that does someting for you (the binding has to be done only one time or try the designer at the datasource)

It works for me, however I have effects I do not understand (and I want to
use the Text property, from that selectedvalue I have the idea that it
works).
Private Sub cboBTLinesSite_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cboBTLinesSite.SelectedIndexChanged
If Me.BindingContext(dsBTLines, "BTLines").Position <> 1 And Not
mlLoading Then
dsBTLines.BTLines.Rows(Me.BindingContext(dsBTLines ,
"BTLines").Position).Item("SitesID") = Me.cboBTLinesSite.SelectedValue
End If
End Sub


Nov 20 '05 #14

P: n/a
Hi Mad,

I will try this tomorrow, this is to heavy for tonight.

Are it comboboxes on a datagrid, because than it will be real heavy for me,
because I only did use the ones with columnstyles comboboxes..

Cor
Nov 20 '05 #15

P: n/a
Hey Cor,

theres no ComboBoxs on the Datagrid, I gave up on that coz it was way out of
my league:) (Well For Now - he he he)
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi Mad,

I will try this tomorrow, this is to heavy for tonight.

Are it comboboxes on a datagrid, because than it will be real heavy for me, because I only did use the ones with columnstyles comboboxes..

Cor

Nov 20 '05 #16

P: n/a
Hi Mad,

I did not look at the messages, however I have made 2 samples for you.
One with a combobox in a datagrid
One with a combobox outside a datagrid.

Have a look at it, it are simple samples.
That was I thought easier for me than looking at your problem.

I send them in seperated messages as thread on this thread.

I hope this helps?

Cor
Nov 20 '05 #17

P: n/a
Mad as told

It is first time made however it should do as I suspect it would do

Cor

\\\needs a datagrid and 2 buttons on a form
'Used for the comboboxcolumn is a modified sample from
'syncfusion
'To start create ds and cancel, than a start dataset
'will be created
Dim ds As New DataSet("Test")
Private Sub Form1_Load(ByVal sender As Object, ByVal e _
As System.EventArgs) Handles MyBase.Load
Me.Button1.Text = "Read/Create ds"
Me.Button2.Text = "Write ds"
End Sub
Private Sub FillGrid()
Dim dv As New DataView(ds.Tables(0))
dv.AllowNew = False
DataGrid1.DataSource = dv
Dim ts As New DataGridTableStyle
ts.MappingName = "Names"
Dim textCol As New DataGridTextBoxColumn
textCol.MappingName = "IdName"
textCol.HeaderText = "Id"
textCol.Width = 20
ts.GridColumnStyles.Add(textCol)
textCol = New DataGridTextBoxColumn
textCol.MappingName = "Name"
textCol.HeaderText = "Name"
textCol.Width = 120
ts.GridColumnStyles.Add(textCol)
Dim cmbTxtCol As New DataGridComboBoxColumn
cmbTxtCol.MappingName = "Country"
cmbTxtCol.HeaderText = "Countries"
cmbTxtCol.Width = 100
ts.GridColumnStyles.Add(cmbTxtCol)
ts.PreferredRowHeight = (cmbTxtCol.ColumnComboBox.Height + 3)
cmbTxtCol.ColumnComboBox.DataSource = ds.Tables(1)
cmbTxtCol.ColumnComboBox.DisplayMember = "Country"
cmbTxtCol.ColumnComboBox.ValueMember = "IdCountry"
cmbTxtCol.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList
DataGrid1.TableStyles.Add(ts)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim of As New SaveFileDialog
If of.ShowDialog = DialogResult.OK Then
ds.WriteXml(of.FileName)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim fo As New OpenFileDialog
If fo.ShowDialog() = DialogResult.OK Then
ds.ReadXml(fo.FileName)
Else
Dim dtName As New DataTable("Names")
Dim dcIdName As New DataColumn("IdName")
Dim dcName As New DataColumn("Name")
Dim dcCountryN As New DataColumn("Country")
dtName.Columns.Add(dcIdName)
dtName.Columns.Add(dcName)
dtName.Columns.Add(dcCountryN)
ds.Tables.Add(dtName)
For i As Integer = 1 To 5
Dim dr As DataRow = dtName.NewRow
dr(0) = i.ToString
dtName.Rows.Add(dr)
Next
dtName.Rows(0)(1) = "Herfried K. Wagner"
dtName.Rows(1)(1) = "Armin Zingler"
dtName.Rows(2)(1) = "Ken Tucker"
dtName.Rows(3)(1) = "CJ Taylor"
dtName.Rows(4)(1) = "Cor Ligthert"
dtName.Rows(0)(2) = "Austria(EU)"
dtName.Rows(1)(2) = "Germany(EU)"
dtName.Rows(2)(2) = "Georgia(US)"
dtName.Rows(3)(2) = "Other(US)"
dtName.Rows(4)(2) = "Holland(EU)"
Dim dtCountry As New DataTable("Countries")
Dim dcIdCountry As New DataColumn("IDCountry")
Dim dcCountry As New DataColumn("Country")
dtCountry.Columns.Add(dcIdCountry)
dtCountry.Columns.Add(dcCountry)
ds.Tables.Add(dtCountry)
For i As Integer = 1 To 5
Dim dr As DataRow = dtCountry.NewRow
dr(0) = i.ToString
dtCountry.Rows.Add(dr)
Next
dtCountry.Rows(0)(1) = "Austria(EU)"
dtCountry.Rows(1)(1) = "Germany(EU)"
dtCountry.Rows(2)(1) = "Holland(EU)"
dtCountry.Rows(3)(1) = "Georgia(US)"
dtCountry.Rows(4)(1) = "Other(US)"
End If
FillGrid()
End Sub
End Class
Public Class DataGridComboBoxColumn
Inherits DataGridTextBoxColumn
Public WithEvents ColumnComboBox As NoKeyUpCombo 'special class
Private WithEvents cmSource As CurrencyManager
Private mRowNum As Integer
Private isEditing As Boolean
Shared Sub New()
End Sub
Public Sub New()
MyBase.New()
ColumnComboBox = New NoKeyUpCombo
AddHandler ColumnComboBox.SelectionChangeCommitted, _
New EventHandler(AddressOf ComboStartEditing)
End Sub
Protected Overloads Overrides Sub Edit(ByVal source As CurrencyManager,
_
ByVal rowNum As Integer, ByVal bounds As Rectangle, ByVal readOnly1 As
Boolean, _
ByVal instantText As String, ByVal cellIsVisible As Boolean)
MyBase.Edit(source, rowNum, bounds, readOnly1, instantText,
cellIsVisible)
mRowNum = rowNum
cmSource = source
ColumnComboBox.Parent = Me.TextBox.Parent
ColumnComboBox.Location = Me.TextBox.Location
ColumnComboBox.Size = New Size(Me.TextBox.Size.Width,
ColumnComboBox.Size.Height)
ColumnComboBox.Text = Me.TextBox.Text
TextBox.Visible = False
ColumnComboBox.Visible = True
ColumnComboBox.BringToFront()
ColumnComboBox.Focus()
End Sub
Protected Overloads Overrides Function Commit(ByVal dataSource As _
CurrencyManager, ByVal rowNum As Integer) As Boolean
If isEditing Then
isEditing = False
SetColumnValueAtRow(dataSource, rowNum, ColumnComboBox.Text)
End If
Return True
End Function
Private Sub ComboStartEditing(ByVal sender As Object, ByVal e As
EventArgs)
isEditing = True
MyBase.ColumnStartedEditing(DirectCast(sender, Control))
End Sub
Private Sub LeaveComboBox(ByVal sender As Object, ByVal e As EventArgs)
_
Handles ColumnComboBox.Leave
If isEditing Then
SetColumnValueAtRow(cmSource, mRowNum, ColumnComboBox.Text)
isEditing = False
Invalidate()
End If
ColumnComboBox.Hide()
End Sub
End Class
Public Class NoKeyUpCombo
Inherits ComboBox
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg <> &H101 Then
MyBase.WndProc(m)
End If
End Sub
End Class
///
Nov 20 '05 #18

P: n/a
Mad,

This should be with what you are busy with the combobox outside

Cor

\\\datagrid sample with combobox outside
'needs a datagrid, a combobox and two buttons on a form
'to start do the button create ds and cancel and a dataset will be created
Dim ds As New DataSet("Test")
Dim dv As DataView
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.Button1.Text = "Read/Create ds"
Me.Button2.Text = "Write ds"
End Sub
Private Sub FillGridCombo()
dv = New DataView(ds.Tables(0))
dv.AllowNew = False
DataGrid1.DataSource = dv
Dim ts As New DataGridTableStyle
ts.MappingName = "Names"
Dim textCol As New DataGridTextBoxColumn
textCol.MappingName = "IdName"
textCol.HeaderText = "Id"
textCol.Width = 20
ts.GridColumnStyles.Add(textCol)
textCol = New DataGridTextBoxColumn
textCol.MappingName = "Name"
textCol.HeaderText = "Name"
textCol.Width = 120
ts.GridColumnStyles.Add(textCol)
textCol = New DataGridTextBoxColumn
textCol.MappingName = "Country"
textCol.HeaderText = "Countries"
textCol.Width = 100
ts.GridColumnStyles.Add(textCol)
DataGrid1.TableStyles.Add(ts)
ComboBox1.DataSource = ds.Tables(1)
ComboBox1.DisplayMember = "Country"
ComboBox1.ValueMember = "Country"
ComboBox1.DataBindings.Add(New Binding("SelectedValue", dv,
"Country"))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim of As New SaveFileDialog
If of.ShowDialog = DialogResult.OK Then
ds.WriteXml(of.FileName)
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles ComboBox1.SelectedIndexChanged
Me.BindingContext(dv).EndCurrentEdit()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim fo As New OpenFileDialog
If fo.ShowDialog() = DialogResult.OK Then
ds.ReadXml(fo.FileName)
Else
Dim dtName As New DataTable("Names")
Dim dcIdName As New DataColumn("IdName")
Dim dcName As New DataColumn("Name")
Dim dcCountryN As New DataColumn("Country")
dtName.Columns.Add(dcIdName)
dtName.Columns.Add(dcName)
dtName.Columns.Add(dcCountryN)
ds.Tables.Add(dtName)
For i As Integer = 1 To 5
Dim dr As DataRow = dtName.NewRow
dr(0) = i.ToString
dtName.Rows.Add(dr)
Next
dtName.Rows(0)(1) = "Herfried K. Wagner"
dtName.Rows(1)(1) = "Armin Zingler"
dtName.Rows(2)(1) = "Ken Tucker"
dtName.Rows(3)(1) = "CJ Taylor"
dtName.Rows(4)(1) = "Cor Ligthert"
dtName.Rows(0)(2) = "Austria(EU)"
dtName.Rows(1)(2) = "Germany(EU)"
dtName.Rows(2)(2) = "Georgia(US)"
dtName.Rows(3)(2) = "Other(US)"
dtName.Rows(4)(2) = "Holland(EU)"
Dim dtCountry As New DataTable("Countries")
Dim dcIdCountry As New DataColumn("IDCountry")
Dim dcCountry As New DataColumn("Country")
dtCountry.Columns.Add(dcIdCountry)
dtCountry.Columns.Add(dcCountry)
ds.Tables.Add(dtCountry)
For i As Integer = 1 To 5
Dim dr As DataRow = dtCountry.NewRow
dr(0) = i.ToString
dtCountry.Rows.Add(dr)
Next
dtCountry.Rows(0)(1) = "Austria(EU)"
dtCountry.Rows(1)(1) = "Germany(EU)"
dtCountry.Rows(2)(1) = "Holland(EU)"
dtCountry.Rows(3)(1) = "Georgia(US)"
dtCountry.Rows(4)(1) = "Other(US)"
End If
FillGridCombo()
End Sub
////
Nov 20 '05 #19

P: n/a
Cor Many Thanks for that i`ll have a look at these over the weekend,
hopefully i`ll be able to get some where. One thing thought if you don`t
mind me asking?

Which code is better to use for updating my Dataset/Database?

This one:

Private Sub btnCentrexLinesUpdate_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnCentrexLinesUpdate.Click
Try
Dim objDataSetChanges As Excellence.NET.dsCentrexLines =
New Excellence.NET.dsCentrexLines()
Me.BindingContext(dsCentrexLines,
"Centrexlines").EndCurrentEdit()
objDataSetChanges = CType(dsCentrexLines.GetChanges,
Excellence.NET.dsCentrexLines)
If (Not (objDataSetChanges) Is Nothing) Then
Try
If (Not (dsCentrexLines) Is Nothing) Then
Me.odcPhones.Open()
Me.odaSites.Fill(dsCentrexLines)
Me.odaDepartments.Fill(dsCentrexLines)
Me.odaPrimaryUser.Fill(dsCentrexLines)
Me.odaCommsType.Fill(dsCentrexLines)
Me.odaCentrexLines.Fill(dsCentrexLines)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPhones.Close()
End Try
End If
dsCentrexLines.Merge(objDataSetChanges)
dsCentrexLines.AcceptChanges()
Catch eUpdate As System.Exception

System.Windows.Forms.MessageBox.Show(eUpdate.Messa ge)
End Try
End Sub

or:

Private Sub btnCentrexLinesUpdate_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnCentrexLinesUpdate.Click
Try
Me.BindingContext(dsCentrexLines,
"Centrexlines").EndCurrentEdit()
If (Not (dsCentrexLines) Is Nothing) Then
Me.odcPhones.Open()
Me.odaSites.Update(dsCentrexLines)
Me.odaDepartments.Update(dsCentrexLines)
Me.odaPrimaryUser.Update(dsCentrexLines)
Me.odaCommsType.Update(dsCentrexLines)
Me.odaCentrexLines.Update(dsCentrexLines)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPhones.Close()
End Try
End If
dsCentrexLines.AcceptChanges()
Catch eUpdate As System.Exception

System.Windows.Forms.MessageBox.Show(eUpdate.Messa ge)
End Try
End Sub

Many Thanks Again
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:O4*************@TK2MSFTNGP11.phx.gbl...
Mad,

This should be with what you are busy with the combobox outside

Cor

\\\datagrid sample with combobox outside
'needs a datagrid, a combobox and two buttons on a form
'to start do the button create ds and cancel and a dataset will be created
Dim ds As New DataSet("Test")
Dim dv As DataView
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.Button1.Text = "Read/Create ds"
Me.Button2.Text = "Write ds"
End Sub
Private Sub FillGridCombo()
dv = New DataView(ds.Tables(0))
dv.AllowNew = False
DataGrid1.DataSource = dv
Dim ts As New DataGridTableStyle
ts.MappingName = "Names"
Dim textCol As New DataGridTextBoxColumn
textCol.MappingName = "IdName"
textCol.HeaderText = "Id"
textCol.Width = 20
ts.GridColumnStyles.Add(textCol)
textCol = New DataGridTextBoxColumn
textCol.MappingName = "Name"
textCol.HeaderText = "Name"
textCol.Width = 120
ts.GridColumnStyles.Add(textCol)
textCol = New DataGridTextBoxColumn
textCol.MappingName = "Country"
textCol.HeaderText = "Countries"
textCol.Width = 100
ts.GridColumnStyles.Add(textCol)
DataGrid1.TableStyles.Add(ts)
ComboBox1.DataSource = ds.Tables(1)
ComboBox1.DisplayMember = "Country"
ComboBox1.ValueMember = "Country"
ComboBox1.DataBindings.Add(New Binding("SelectedValue", dv,
"Country"))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim of As New SaveFileDialog
If of.ShowDialog = DialogResult.OK Then
ds.WriteXml(of.FileName)
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles ComboBox1.SelectedIndexChanged
Me.BindingContext(dv).EndCurrentEdit()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim fo As New OpenFileDialog
If fo.ShowDialog() = DialogResult.OK Then
ds.ReadXml(fo.FileName)
Else
Dim dtName As New DataTable("Names")
Dim dcIdName As New DataColumn("IdName")
Dim dcName As New DataColumn("Name")
Dim dcCountryN As New DataColumn("Country")
dtName.Columns.Add(dcIdName)
dtName.Columns.Add(dcName)
dtName.Columns.Add(dcCountryN)
ds.Tables.Add(dtName)
For i As Integer = 1 To 5
Dim dr As DataRow = dtName.NewRow
dr(0) = i.ToString
dtName.Rows.Add(dr)
Next
dtName.Rows(0)(1) = "Herfried K. Wagner"
dtName.Rows(1)(1) = "Armin Zingler"
dtName.Rows(2)(1) = "Ken Tucker"
dtName.Rows(3)(1) = "CJ Taylor"
dtName.Rows(4)(1) = "Cor Ligthert"
dtName.Rows(0)(2) = "Austria(EU)"
dtName.Rows(1)(2) = "Germany(EU)"
dtName.Rows(2)(2) = "Georgia(US)"
dtName.Rows(3)(2) = "Other(US)"
dtName.Rows(4)(2) = "Holland(EU)"
Dim dtCountry As New DataTable("Countries")
Dim dcIdCountry As New DataColumn("IDCountry")
Dim dcCountry As New DataColumn("Country")
dtCountry.Columns.Add(dcIdCountry)
dtCountry.Columns.Add(dcCountry)
ds.Tables.Add(dtCountry)
For i As Integer = 1 To 5
Dim dr As DataRow = dtCountry.NewRow
dr(0) = i.ToString
dtCountry.Rows.Add(dr)
Next
dtCountry.Rows(0)(1) = "Austria(EU)"
dtCountry.Rows(1)(1) = "Germany(EU)"
dtCountry.Rows(2)(1) = "Holland(EU)"
dtCountry.Rows(3)(1) = "Georgia(US)"
dtCountry.Rows(4)(1) = "Other(US)"
End If
FillGridCombo()
End Sub
////

Nov 20 '05 #20

P: n/a
Hi Mad,

I go just for this simple one.

Me.BindingContext(dsCentrexLines).EndCurrentEdit()
If dsCentrexLines.haschanges Then
Try
Me.odcPhones.Open()
Me.odaSites.Update(dsCentrexLines, "rigthtable")
'rightable=Sites?
Me.odaDepartments.Update(dsCentrexLines, "rigthtable")
Me.odaPrimaryUser.Update(dsCentrexLines, "rigthtable")
Me.odaCommsType.Update(dsCentrexLines, "rigthtable")
Me.odaCentrexLines.Update(dsCentrexLines, "rigthtable")
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.odcPhones.Close()
End Try
End if
' And if there are no error or/an you have resolved them than the Fill's
again to do an update from your dataset when other users has added new
lines.

The dataadapter update does with a full dataset a lot of things for you.

I hope you succeed in the weekend

Cor
Nov 20 '05 #21

This discussion thread is closed

Replies have been disabled for this discussion.