Wednesday, March 21, 2012

Passsing a connection object

I have a class that creates a connection to the database. When I call this object from my aspx code behind to get a connection to the database I get an error.
Object reference not set to an instance of an object.
How can I pass a connction object back from a class to a aspx code behind.pls post some code so that we might see the problem ...
if an object is not marked as Shared, you need to instantiate it before calling any of its methods.

based on your error you may have something like this:

dim oConn as MyConnectionObject
dim something as string
something = oConn.GetConnString

this will fail

you need

dim oConn asNew MyConnectionObject
dim something as string
something = oConn.GetConnString

0 comments:

Post a Comment