Solved

An SqlParameter with ParameterName '@doctors_expiration_date' is not contained by this SqlParameterCollection.

Posted on 2010-09-20
10
661 Views
Last Modified: 2012-05-10
I'm not certain why this is occurring. Please take a look at my code and let me know if you require more info. SP below VB code. Thank you!

"    at Microsoft.VisualBasic.ErrObject.Raise(Int32 Number, Object Source, Object Description, Object HelpFile, Object HelpContext)
   at LinePopulation.CheckTbCertification(String& strLineTitle, Int32& lngLineCandidatesID, String& strSS_Number, Boolean[]& ablnRequirementChecks) in C:\Documents\App Development\STS_Rewrite\STS (to DOT(34).NET) (LinePopulation Class)\App_Code\LinePopulation.vb:line 189
   at WebService._CheckTbCertification() in C:\Documents\App Development\STS_Rewrite\STS (to DOT(34).NET) (LinePopulation Class)\App_Code\WebService.vb:line 37"

Public Sub CheckTbCertification( _

        ByRef strLineTitle As String, _

        ByRef lngLineCandidatesID As Integer, _

        ByRef strSS_Number As String, _

        ByRef ablnRequirementChecks() As Boolean)



        On Error GoTo ErrorTrap



        Const c_VtcTbCertCode As String = "05"

        Dim utCandidateLineDates As utStartEndDates

        Const c_PhysicalExamTbTitleCodes As String = "|60430|06070|60405|60440|06664|"



        If InStr(c_PhysicalExamTbTitleCodes, strLineTitle) Then

            utCandidateLineDates = SingleLineCandidateDateRange(lngLineCandidatesID)



            Dim cmd As New SqlCommand

            cmd.CommandText = "ps__employee_vtc_data_SELECT_VtcTbResults"

            cmd.CommandType = CommandType.StoredProcedure



            cmd.Parameters.AddWithValue("@ssn", strSS_Number)

            cmd.Parameters.AddWithValue("@tb_test__cd", c_VtcTbCertCode)



            Dim param As New SqlClient.SqlParameter("@tb_result", SqlDbType.VarChar, 1)

            param.Direction = ParameterDirection.Output

            cmd.Parameters.Add(param)



            param = New SqlClient.SqlParameter("@doctors_expiration_dt", SqlDbType.DateTime, 4)

            param.Direction = ParameterDirection.Output

            cmd.Parameters.Add(param)



            Dim cnn As New Connection

            cnn.OpenConnection()

            cmd.Connection() = cnn.GetConnection

            cmd.ExecuteReader()



            If IsDBNull(cmd.Parameters("@doctors_expiration_date").Value) Then

                ablnRequirementChecks(rqcRequirementChecks.rqcTbCertificationRequired) = True

            ElseIf cmd.Parameters("@doctors_expiration_date").Value < utCandidateLineDates.utStartDate Then

                ablnRequirementChecks(rqcRequirementChecks.rqcTbCertificationRequired) = True

            ElseIf cmd.Parameters("@doctors_expiration_date").Value >= utCandidateLineDates.utStartDate Then

                If cmd.Parameters("@tb_result").Value = mc_Failed Then

                    ablnRequirementChecks(rqcRequirementChecks.rqcTbTestPositive) = True

                End If

            End If



            cnn.CloseConnection()

            cmd = Nothing

        End If



        On Error GoTo 0

        Exit Sub

ErrorTrap:

        Err.Raise(Err.Number, "LinePopulation.CheckTbCertification > " & Err.Source, Err.Description)

        On Error GoTo 0

    End Sub



SP---------------------------------'



ALTER PROCEDURE [dbo].[ps__employee_vtc_data_SELECT_VtcTbResults]

(

@ssn						char(11),

@tb_test__cd				char(2),

@tb_result					char(1)			OUTPUT,

@doctors_expiration_dt		datetime		OUTPUT

)

AS



SELECT 	@tb_result = vtc_result,

		@doctors_expiration_dt = doctors_expiration_dt

FROM 	employee_vtc_data

WHERE 	ssn = @ssn AND

		vtc_cd = @tb_test__cd AND

		emp_vtc__id =

		(

			SELECT 	MAX(emp_vtc__id)

			FROM 	employee_vtc_data

			WHERE 	ssn = @ssn AND

					vtc_cd = @tb_test__cd

		);

Open in new window

0
Comment
Question by:bobcann
  • 6
  • 4
10 Comments
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33719205
hi
change param to param1,param2,param3 according to how many parameters you have...
and then set
cmd.Parameters.Add(Param1) and so on
Hope it helps...
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33719320
like this...
            Dim param1 As New SqlClient.SqlParameter("@tb_result", SqlDbType.VarChar, 1)

            param1.Direction = ParameterDirection.Output

            cmd.Parameters.Add(param1)



            Dim param2 As New SqlClient.SqlParameter("@doctors_expiration_dt", SqlDbType.DateTime, 4)

            param2.Direction = ParameterDirection.Output

            cmd.Parameters.Add(param2)

Open in new window

0
 

Author Comment

by:bobcann
ID: 33719796
jtoutou, I just tried it, but it doesn't work.
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33720702
try this....
Open the connection first ...then declare the parameters...and after the parameter declaretion execute the reader..Modify like below...
Public Sub CheckTbCertification( _

        ByRef strLineTitle As String, _

        ByRef lngLineCandidatesID As Integer, _

        ByRef strSS_Number As String, _

        ByRef ablnRequirementChecks() As Boolean)



        On Error GoTo ErrorTrap



        Const c_VtcTbCertCode As String = "05"

        Dim utCandidateLineDates As utStartEndDates

        Const c_PhysicalExamTbTitleCodes As String = "|60430|06070|60405|60440|06664|"



        If InStr(c_PhysicalExamTbTitleCodes, strLineTitle) Then

            utCandidateLineDates = SingleLineCandidateDateRange(lngLineCandidatesID)

           

            Dim cnn As New Connection

            cnn.OpenConnection()

            

            Dim cmd As New SqlCommand

            cmd.CommandText = "ps__employee_vtc_data_SELECT_VtcTbResults"

            cmd.CommandType = CommandType.StoredProcedure



            cmd.Connection() = cnn.GetConnection

            

            cmd.Parameters.AddWithValue("@ssn", strSS_Number)

            cmd.Parameters.AddWithValue("@tb_test__cd", c_VtcTbCertCode)



            Dim param1 As New SqlClient.SqlParameter("@tb_result", SqlDbType.VarChar, 1)

            param1.Direction = ParameterDirection.Output

            cmd.Parameters.Add(param1)



            dim param2 As New SqlClient.SqlParameter("@doctors_expiration_dt", SqlDbType.DateTime, 4)

            param2.Direction = ParameterDirection.Output

            cmd.Parameters.Add(param2)



            

            



            If IsDBNull(cmd.Parameters("@doctors_expiration_date").Value) Then

                ablnRequirementChecks(rqcRequirementChecks.rqcTbCertificationRequired) = True

            ElseIf cmd.Parameters("@doctors_expiration_date").Value < utCandidateLineDates.utStartDate Then

                ablnRequirementChecks(rqcRequirementChecks.rqcTbCertificationRequired) = True

            ElseIf cmd.Parameters("@doctors_expiration_date").Value >= utCandidateLineDates.utStartDate Then

                If cmd.Parameters("@tb_result").Value = mc_Failed Then

                    ablnRequirementChecks(rqcRequirementChecks.rqcTbTestPositive) = True

                End If

            End If

           cmd.ExecuteReader()

            cnn.CloseConnection()

            cmd = Nothing

        End If



        On Error GoTo 0

        Exit Sub

ErrorTrap:

        Err.Raise(Err.Number, "LinePopulation.CheckTbCertification > " & Err.Source, Err.Description)

        On Error GoTo 0

    End Sub

Open in new window

0
 

Author Comment

by:bobcann
ID: 33726215
I get this new message using your version. This is the way things seem to be in dot.net, fix one problem and create another. What do you think?
System.IndexOutOfRangeException: An SqlParameter with ParameterName '@doctors_expiration_date' is not contained by this SqlParameterCollection.

   at Microsoft.VisualBasic.ErrObject.Raise(Int32 Number, Object Source, Object Description, Object HelpFile, Object HelpContext)

   at LinePopulation.CheckTbCertification(String& strLineTitle, Int32& lngLineCandidatesID, String& strSS_Number, Boolean[]& ablnRequirementChecks) in C:\Documents\App Development\STS_Rewrite\STS (to DOT(37).NET) ()\App_Code\LinePopulation.vb:line 201

   at

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Accepted Solution

by:
John (Yiannis) Toutountzoglou earned 500 total points
ID: 33726268
What is the value you pass in @doctors_expiration_date..could you post your finally Code?
0
 

Author Comment

by:bobcann
ID: 33728712
Here is the code. @doctors_expiration_date is a return parameter. It's a VB 6 rewrite with no time for .NET error handling.
 Public Sub CheckTbCertification( _

        ByRef strLineTitle As String, _

        ByRef lngLineCandidatesID As Integer, _

        ByRef strSS_Number As String, _

        ByRef ablnRequirementChecks() As Boolean)



        On Error GoTo ErrorTrap



        Const c_VtcTbCertCode As String = "05"

        Dim utCandidateLineDates As utStartEndDates

        Const c_PhysicalExamTbTitleCodes As String = "|60430|06070|60405|60440|06664|"



        If InStr(c_PhysicalExamTbTitleCodes, strLineTitle) Then

            utCandidateLineDates = SingleLineCandidateDateRange(lngLineCandidatesID)



            Dim cnn As New Connection

            cnn.OpenConnection()



            Dim cmd As New SqlCommand

            cmd.CommandText = "ps__employee_vtc_data_SELECT_VtcTbResults"

            cmd.CommandType = CommandType.StoredProcedure



            cmd.Connection() = cnn.GetConnection



            cmd.Parameters.AddWithValue("@ssn", strSS_Number)

            cmd.Parameters.AddWithValue("@tb_test__cd", c_VtcTbCertCode)



            Dim param1 As New SqlClient.SqlParameter("@tb_result", SqlDbType.VarChar, 1)

            param1.Direction = ParameterDirection.Output

            cmd.Parameters.Add(param1)



            Dim param2 As New SqlClient.SqlParameter("@doctors_expiration_dt", SqlDbType.DateTime, 4)

            param2.Direction = ParameterDirection.Output

            cmd.Parameters.Add(param2)



            If IsDBNull(cmd.Parameters("@doctors_expiration_date").Value) Then

                ablnRequirementChecks(rqcRequirementChecks.rqcTbCertificationRequired) = True

            ElseIf cmd.Parameters("@doctors_expiration_date").Value < utCandidateLineDates.utStartDate Then

                ablnRequirementChecks(rqcRequirementChecks.rqcTbCertificationRequired) = True

            ElseIf cmd.Parameters("@doctors_expiration_date").Value >= utCandidateLineDates.utStartDate Then

                If cmd.Parameters("@tb_result").Value = mc_Failed Then

                    ablnRequirementChecks(rqcRequirementChecks.rqcTbTestPositive) = True

                End If

            End If

            cmd.ExecuteReader()

            cnn.CloseConnection()

            cmd = Nothing

        End If



        On Error GoTo 0

        Exit Sub

ErrorTrap:

        Err.Raise(Err.Number, "LinePopulation.CheckTbCertification > " & Err.Source, Err.Description)

        On Error GoTo 0

    End Sub

Open in new window

0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33730017
From where the @doctors_expiration_dt takes its value?
0
 

Author Closing Comment

by:bobcann
ID: 33736279
Hi jtoutou,

My bad. Typo and not initializing an array... I hope I never have to rewrite another coders app.

Thanks for looking at it. I'll be posting more questions, hopefully with code with no typos :)

--Bob
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33736941
Very Welcome
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with checking if excel exist in client's computer 9 43
Tabcontrol Caption? 1 31
how to use laptop or pad camera in vb.net windows application 2 55
vb.net checkbox 7 41
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now