Asp.Net VB help

Hi

I've got some code that is suppose to set a session variable and name a textbox depending on whether the record set is populated or not but its not working.

I don't get any errors but it just does nothing whether the recorded is populated or not.   Can someone tell me why?

While objComp3.Read()

            If objComp3("TRAINEEID") IsNot Nothing Then

                Session("IQAComplianceMode") = "Update"

                btnComplianceButton.Text = "Update Complance"

            Else

                Session("IQAComplianceMode") = "Insert"

                btnComplianceButton.Text = "Add Complance"
            End If

            labeltest.text = objComp3("TRAINEEID").ToString

            End While

Open in new window

EdAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lokesh B RDeveloperCommented:
Hi,

Where is your query which is populating this SqlDataReader?
can you share the full code for this method.

Check this code

If objComp3.HasRows Then
	If objComp3.Read() Then
		If objComp3("TRAINEEID") IsNot Nothing Then
			Session("IQAComplianceMode") = "Update"
			btnComplianceButton.Text = "Update Complance"
		Else
			Session("IQAComplianceMode") = "Insert"
			btnComplianceButton.Text = "Add Complance"
		End If

		labeltest.text = objComp3("TRAINEEID").ToString()
	End If
End If

Open in new window

0
EdAuthor Commented:
Here the whole code

            '' Load IQA COmplance''''''''''''

            Dim CompGetCOnn As SqlConnection
            Dim ComGetComm As SqlCommand
            Dim objComp3 As SqlDataReader
            Dim connectionStringIQA As String = ConfigurationManager.ConnectionStrings("IRISConnectionString").ConnectionString
            CompGetCOnn = New SqlConnection(connectionStringIQA)
            ComGetComm = New SqlCommand()

            ComGetComm.Connection = CompGetCOnn

            ComGetComm.CommandType = CommandType.StoredProcedure

            ComGetComm.CommandText = "GET_IQA_Compliance"

            ComGetComm.Parameters.Add("@IVRECORDID", SqlDbType.Int).Value = GridIVRecs.SelectedDataKey.Value

            CompGetCOnn.Open()
            objComp3 = ComGetComm.ExecuteReader()

            While objComp3.Read()

            If objComp3("TRAINEEID") IsNot Nothing Then

                Session("IQAComplianceMode") = "Update"

                btnComplianceButton.Text = "Update Complance"

            Else

                Session("IQAComplianceMode") = "Insert"

                btnComplianceButton.Text = "Add Complance"
            End If

            labeltest.text = objComp3("TRAINEEID").ToString

            End While

            objComp3.Close()
            CompGetCOnn.Close()


        tcIQADetail.ActiveTabIndex = 0

Open in new window

0
Lokesh B RDeveloperCommented:
Hi,

Did you try my code?

keep break point and see whether you have rows in reader.
0
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

EdAuthor Commented:
I tried the code you posted but still the same.
0
EdAuthor Commented:
keep break point and see whether you have rows in reader.

How do I do that?
0
Lokesh B RDeveloperCommented:
Hi,

Right Click on the below line and Select Breakpoint and Select Insert break point and see whether it goes inside the loop or not.

If objComp3.HasRows Then

Run the application and see
http://csharp.net-tutorials.com/debugging/breakpoints/
0
EdAuthor Commented:
Final Solution is


        While objComp3.Read()

            If objComp3("TRAINEEID") = DBNull.Value Then

                Session("IQAComplianceMode") = "Update"
                btnComplianceButton.Text = "Update Complance"

            Else



                Session("IQAComplianceMode") = "Insert"
                btnComplianceButton.Text = "Add Complance"



            End If
            End While

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EdAuthor Commented:
Found the correct code to use after stepping through code, thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.