Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Function DispalyGuardianDetials(ByVal UserName As String, ByVal Stype As Integer) As Integer
       Dim Sqlcust As String
       Dim Phonenumber As String
       Dim spt() As String
       Dim i As Int16
       Sqlcust = ""
       If Stype = 0 Then
           Sqlcust = "select*from Tbl_MstGuardian where CONTACTNAME='" & UserName & "'"
       ElseIf Stype = 1 Then
           Sqlcust = "select*from Tbl_MstGuardian where Maxid='" & UserName & "'"
       End If
       'Call clearfieldsGaurdian()
       Rsc = New SqlCommand(Sqlcust, con)
       'Rsc.ExecuteNonQuery()
       Rsd = Rsc.ExecuteReader()
       If Rsd.Read = True Then

           TxtGname.Text = Rsd("contactname")
           TxtGucode.Text = Rsd("usercode")
                               The error is Index out of range exception was unhandled by usercode            
           TxtGAge.Text = Rsd("AGE")
           TxtGDob.Text = Rsd("DOB")
           TxtGRelationship.Text = Rsd("relationship")
           TxtGAdd.Text = Rsd("ADDRESS1")
           TxtGLand.Text = Rsd("landmark")
           TxtGPin.Text = Rsd("pincode")
           TxtGArea.Text = Rsd("area")
           TxtGCity.Text = Rsd("city")
           TxtGState.Text = Rsd("state")
           TxtGCountry.Text = Rsd("country")
Posted
Comments
walterhevedeich 4-May-12 1:15am    
Are you sure that all columns you are trying to access from your DataReader exist on your Tbl_MstGuardian table?
Manoj K Bhoir 4-May-12 3:10am    
Verify That All Columns Refered in DataReader Object are exist in Table and The Names Of Columns In DataBase and Name Passed In DataReader Object Must Be Same!

verify that you have usercode column in Tbl_MstGuardian table.

May be column not exists or spelling mistake in column name.
 
Share this answer
 
The preferred way of fixing the error is to place a break point in the method on the statement which is just before where the error occurs, step through the code by each statement and verify the values using Watch window when the execution stops at the break point.
 
Share this answer
 
Comments
Maciej Los 4-May-12 12:38pm    
5 for "how to fix errors" tip ;)
VJ Reddy 4-May-12 12:40pm    
Thank you, losmac.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900