troubleshooting Question

Problem creating a sql parameter array and loading data from it.

Avatar of Slimshaneey
SlimshaneeyFlag for United Kingdom of Great Britain and Northern Ireland asked on
Visual Basic.NET
8 Comments1 Solution582 ViewsLast Modified:
Hi there. I have 2 functions that are supposed to be complimenting each other but I cant seem to get it working. Basically I have a datahelper module that returns datasets. Its parameters are the name of the SP to run and the SQLParameterCollection to hold its parameters. One of my functions basically isnt working when trying to create the parametercollection. The code I am using is as  follows...

Public Function ReturnUser(ByVal guidContactID As Guid) As ArkUser
'Custom Class
        Dim objTmpArk As ArkUser
'Another Custom class
        Dim objDataHelper As New DataHelper
'Create the collection
        Dim pParamArray As SqlParameterCollection

        Dim objTmpReader As SqlDataReader

'Add to the parameter array?
        pParamArray.Add(New SqlParameter("@ContID", SqlDbType.UniqueIdentifier).Value = guidContactID)

        objTmpReader = objDataHelper.ReturnDataReader("sp_ContactID", pParamArray)

        LoadUser(objTmpReader, objTmpArk)

        Return objTmpArk



    End Function
Howeever I cant seem to get the loading as I get the error "Object reference no set to an instance of an object" error on the line pParamarray.Add...

Anyone shed some light on this?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros