Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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??!

  • *Experts*
Posted

Then are you sure that your sqlConn is indeed null? Try setting the

declaration line of 'sqlConn' to

SqlConnection sqlConn = null;

Posted

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!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...