So basic it hurts!!

axum

Freshman
Joined
Mar 28, 2003
Messages
40
Ok i have this at the top of my page :

private SqlConnection sqlConn = new SqlConnection();

and i have a createDBConnection function, that gets called a lot.

How do i write this line :

If sqlConn Is Nothing Then
'create connection
end if

but in C#??? How do i check if sqlConn is set to anything yet??

HELP!!

Axum
 
hehe, ok...

i have this:

if (sqlConn == null)
{
string strDbConn;
strDbConn = "Integrated Security=True;Data Source=local;Initial Catalog=Taxonomy;";
sqlConn = new SqlConnection(strDbConn);
}

but now when i run it, the string never gets run? then when i try and fill my Dataset it says missing connectionString property??!
 
Then are you sure that your sqlConn is indeed null? Try setting the
declaration line of 'sqlConn' to
C#:
SqlConnection sqlConn = null;
 
well it's within an ASP.NET code-behind page, so it gets run once, then gets run on every postback....

i think i may just leave it out!!
 
Back
Top