PC Review


Reply
Thread Tools Rate Thread

Ado - Driving me Nuts

 
 
MadCrazyNewbie
Guest
Posts: n/a
 
      24th Mar 2004
Hey Group,

I keep getting the following Error and its driving me nuts now.

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

it keeps erroring on this line:
Private Sub dsPasswordlist_PositionChanged()
If Me.BindingContext(dsPasswordList, "PasswordList").Position <> -1 Then
Me.cboPasswordListsDepartment.SelectedValue =
dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
"PasswordList").Position).Item("DepartmentID")
End If
End Sub

Anybody got any Ideas?

Many Thanks
Si


 
Reply With Quote
 
 
 
 
Robin Tucker
Guest
Posts: n/a
 
      24th Mar 2004
You know what? I'm getting exactly the same exception, intermittantly, on
one of my list boxes. What I've done to "get around" it is to wrap the
statement in a try...catch so that it doesn't happen at runtime. Its
totally weird and, I think, a bug (at least I hope it is). For me, it
doesn't matter too much if the operation fails. For you, I don't know.

"MadCrazyNewbie" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey Group,
>
> I keep getting the following Error and its driving me nuts now.
>
> "An unhandled exception of type 'System.IndexOutOfRangeException' occurred
> in system.data.dll
> Additional information: There is no row at position 1."
>
> it keeps erroring on this line:
> Private Sub dsPasswordlist_PositionChanged()
> If Me.BindingContext(dsPasswordList, "PasswordList").Position <> -1

Then
> Me.cboPasswordListsDepartment.SelectedValue =
> dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
> "PasswordList").Position).Item("DepartmentID")
> End If
> End Sub
>
> Anybody got any Ideas?
>
> Many Thanks
> Si
>
>



 
Reply With Quote
 
MadCrazyNewbie
Guest
Posts: n/a
 
      24th Mar 2004
Hey Robin,

What would be the best way to use Try and Catch in this senario?

Regards
MCN

"Robin Tucker" <(E-Mail Removed)> wrote in
message news:c3sf40$a40$1$(E-Mail Removed)...
> You know what? I'm getting exactly the same exception, intermittantly, on
> one of my list boxes. What I've done to "get around" it is to wrap the
> statement in a try...catch so that it doesn't happen at runtime. Its
> totally weird and, I think, a bug (at least I hope it is). For me, it
> doesn't matter too much if the operation fails. For you, I don't know.
>
> "MadCrazyNewbie" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hey Group,
> >
> > I keep getting the following Error and its driving me nuts now.
> >
> > "An unhandled exception of type 'System.IndexOutOfRangeException'

occurred
> > in system.data.dll
> > Additional information: There is no row at position 1."
> >
> > it keeps erroring on this line:
> > Private Sub dsPasswordlist_PositionChanged()
> > If Me.BindingContext(dsPasswordList, "PasswordList").Position <> -1

> Then
> > Me.cboPasswordListsDepartment.SelectedValue =
> > dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
> > "PasswordList").Position).Item("DepartmentID")
> > End If
> > End Sub
> >
> > Anybody got any Ideas?
> >
> > Many Thanks
> > Si
> >
> >

>
>



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      24th Mar 2004
Hi Mad,

When that Private sub ds.... is called, because that we cannot see.

In this case you can even put that dump try and catch block around it
because there is nothing really that could be catched. It would only be a
much more time consuming method than just set a flag around it when it is,
as I asume, in the initialization fase of the dataset or combobox.

Cor

> Private Sub dsPasswordlist_PositionChanged()
> If Me.BindingContext(dsPasswordList, "PasswordList").Position <> -1

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



 
Reply With Quote
 
Robin Tucker
Guest
Posts: n/a
 
      24th Mar 2004

Well first of all, you need to de-obfuscate your code, something like this:

Private Sub dsPasswordlist_PositionChanged()

Dim thePosition as integer = BindingContext ( dsPasswordList,
"PasswordList" ).Position

If thePosition <> -1 Then

try

cboPasswordListsDepartment.SelectedValue =
dsPasswordList.PasswordList.Rows(thePosition).Item ("DepartmentID")

catch ex as Exception

' Take appropriate alternative action here.

End Try

End If

End Sub

If you look at my problem here, you can see how illogical the exception is.
I am even guarding the access with a check! I mean I say if the count of
selectedindices is one, then get me the zeroth (first) item. Still, very
occassionally, it raises the indexoutofrange exception.

Try
If ListBox.SelectedIndices.Count = 1 Then

' will occassionally get an "indexoutofrangeexception' if you use
' SelectedIndex property. So I use SelectedIndices(0) here instead,
' which seems to hold the correct value, but still can cause the
exception.
' This will have to be looked further into at some point.

If ListBox.SelectedIndices(0) >= 0 Then
Return ListBox.SelectedIndices(0)
End If
End If

Catch Ex As IndexOutOfRangeException

End Try



"MadCrazyNewbie" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey Robin,
>
> What would be the best way to use Try and Catch in this senario?
>
> Regards
> MCN
>
> "Robin Tucker" <(E-Mail Removed)> wrote in
> message news:c3sf40$a40$1$(E-Mail Removed)...
> > You know what? I'm getting exactly the same exception, intermittantly,

on
> > one of my list boxes. What I've done to "get around" it is to wrap the
> > statement in a try...catch so that it doesn't happen at runtime. Its
> > totally weird and, I think, a bug (at least I hope it is). For me, it
> > doesn't matter too much if the operation fails. For you, I don't know.
> >
> > "MadCrazyNewbie" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hey Group,
> > >
> > > I keep getting the following Error and its driving me nuts now.
> > >
> > > "An unhandled exception of type 'System.IndexOutOfRangeException'

> occurred
> > > in system.data.dll
> > > Additional information: There is no row at position 1."
> > >
> > > it keeps erroring on this line:
> > > Private Sub dsPasswordlist_PositionChanged()
> > > If Me.BindingContext(dsPasswordList, "PasswordList").Position

<> -1
> > Then
> > > Me.cboPasswordListsDepartment.SelectedValue =
> > > dsPasswordList.PasswordList.Rows(Me.BindingContext(dsPasswordList,
> > > "PasswordList").Position).Item("DepartmentID")
> > > End If
> > > End Sub
> > >
> > > Anybody got any Ideas?
> > >
> > > Many Thanks
> > > Si
> > >
> > >

> >
> >

>
>



 
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
Driving me nuts! duaneorama@gmail.com Microsoft Outlook Form Programming 0 12th Apr 2006 05:52 PM
This is driving me nuts Alan H Windows XP Video 4 31st Mar 2006 04:35 AM
This is driving me nuts!! =?Utf-8?B?Um9iZXJ0TQ==?= Microsoft Access Queries 3 5th Oct 2005 09:30 AM
HELP! This is driving me nuts... Webwarlock Anti-Virus 3 30th Dec 2004 01:38 AM
This is driving me nuts!!! Lee Microsoft Access Form Coding 5 2nd Jul 2003 10:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:27 AM.