Checking db connection for initialising

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am passing an sqlconnection optional parameter as below;

Optional ByVal DBConn As SqlClient.SqlConnection = Nothing

I have given it an initial value of nothing howee rwhe I try to test for
nothing like;

If DBConn = Nothing

I get an 'Operator '=' is not defined for types
'System.Data.SqlClient.SqlConnection' and
'System.Data.SqlClient.SqlConnection' error. What am I missing and how can I
check if a value was in fact passed for the optional parameter DBConn?

Thanks

Regards
 
Hi

I am passing an sqlconnection optional parameter as below;

Optional ByVal DBConn As SqlClient.SqlConnection = Nothing

I have given it an initial value of nothing howee rwhe I try to test for
nothing like;

If DBConn = Nothing

I get an 'Operator '=' is not defined for types
'System.Data.SqlClient.SqlConnection' and
'System.Data.SqlClient.SqlConnection' error. What am I missing and how can I
check if a value was in fact passed for the optional parameter DBConn?

Thanks

Regards

*sigh*

You should uninstall Visual Studio and shut down your computer and
leave it that way. The solution to this problem can only be found by
having at least one of two important skills, which judging from this
and previous posts it seems you are lacking both:

1) Understanding basic programming
2) Being able to use Google

But just for kicks, I'll copy and paste your error message into Google
and give you the link:

http://www.google.com/search?hl=en&q='Operator+'='+is+not+defined+for+types&btnG=Google+Search

Top link being the following which clearly answers your question:

http://msdn.microsoft.com/en-us/library/tctb58tw(VS.80).aspx

Thanks,

Seth Rowe [MVP]
 
Seth's sarcastic answer aside (he seems to have forgotten that newsgroups
aren't just for experienced programmers),

The equal sign (=) can't be used to check if something is nothing, instead
you use the actual keyword "is".

If DBConn Is Nothing Then...

-Scott
 
Back
Top