Re: How to manually check for a DB connection at the Form Load event?

From: Eric Lemmon (E_MAIL_ME_AT_ericnlisa_at_hotmail.com)
Date: 05/17/04


Date: Mon, 17 May 2004 08:48:40 -0500

Hi Tim,

When loading your form, you will not have any connections available to the database yet. Each instance of the app requires its own connection.

With regards to checking for existing connections (I assume you mean connections made by any app on your machine), it is theoretically possible. However, it will be much less of a headache to just open another connection. However, if you want to go that route, you might want to look into Windows Management Instrumentation (WMI) programming to get the job done. Below are a couple newsgroups that might be more helpful:

microsoft.public.windows.windowsxp.wmi
microsoft.public.sqlserver.connect

Take care,

Eric

"Tim" <DotNetTim@netscape.net> wrote in message news:u$xxJS%23OEHA.3300@TK2MSFTNGP09.phx.gbl...
> Hello.. I have VB.NET 2003 Standard or Pro edtion and today I thought
> about using it to develop a Windows App that would allow my client to
> update a database (SQL server 2000) that resides on my Dot Net Web
> Hosting at a remote site. The Database has about 5 tables that hold
> information that will be queried and written to a Data Grid on the Web
> Form, but to do Inserts, and Updates, etc, I wanted to be able to use
> VB. Well, I tried to use the Data Tools, and I received a message when I
> was setting up my connection that my version of VB didn't allow any
> connection to any SQL server except MSDE on my local machine.. So, I
> know I can do it with code, but now I have to check to see if a
> connection exists, and if it doesn't I need to maually connect to the
> database I'm thinking when my first form loads / splash screen so that I
> can load as much as possible right up front.. (Should I not do this? )..
> I could of course connect to the Database manually in code with the a
> button click to do an insert, edit, etc.. but I wanted to do so when the
> app opens.. Any help in the approach or examples on the web would
> greatly be apprecaited as I'm new to Dot Net, and VB.NET in paticular as
> I'm an old ASP guy..
>
> Thanks
> Tim
>