Re: Why am I getting two connection in ENTERPRISE MANAGER
Because your calling "New" twice. Once in the function and a second time when your Dimming the variable in your ADC form. I dont have 2005 installed but it appears to be the issue. Just do a ...
VB Code:
Dim db As Database
db.EstablishConnect("fps-lap-sz", "funds")
You need to have your EstablishConnect function return the SqlClient.SqlConnection so your only instanciating it in the function.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Why am I getting two connection in ENTERPRISE MANAGER
Ok, thats how I learned .net. Jumped into a large project without even knowing how to show a form.
Since I cant test your code as I only have 2003. But I may be wrong. If you have EM open and connected to your db then that also coulds as a connection.
For reference these are the two sections that I found relevant.
VB Code:
Public Class Database
Public Connection As SqlClient.SqlConnection
Public Function EstablishConnect(ByVal strServer As String, ByVal strDatabase As String)
Re: Why am I getting two connection in ENTERPRISE MANAGER
No - I am not counting the EM connection. EM shows the APP connected to it. To be clear, I actually compiled the .Net mess into an .exe and ran it.
At first, I had the connection call in the child form. First child form got me two connections. Second child form got me three connections. Where is this rogue connection coming from? Must be the OO ooze
The program is not all that big - actually, about 10 lines of code. Am I confusing something in stepping through code in .Net? If I set a break at the .OPEN call in the CLASS and it only stops there once, why would two connections be in the EM list?
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Re: Why am I getting two connection in ENTERPRISE MANAGER
You didnt use any wizard gui to create your db connection either? If you just press F11 you can step through your entire program. Step through it and check EM to see where the connection gets created and continue on until you get to the second one.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Why am I getting two connection in ENTERPRISE MANAGER
Sorry to do the evil bump...
If anyone with good .Net debugging skills could tell me why this simple app is creating two connections to the database, I would surely appreciate it.
I set a breakpoint at the .OPEN in the DATABASE CLASS and it only arrives at that spot once, but EM is showing two connections.
I've tested this from a compiled .EXE as well.
When I had the call to the class in the MDI child form it appeared that I got two connections on the first child form, and then a third connection when the second child was open and a fourth when the third child was open.
Seems a rogue initial connection is somehow being created.
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".