473,473 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Storing Connection in Application_OnStart

yop
All

I need to store a connection in the application object
due to the need to use MYSQL and its very poor connection
pooling.

Would someone have an example as the code below is not
working correctly.

Thanks

Sub Application_Start(ByVal sender As Object, ByVal e As
EventArgs)
' Fires when the application is started
Dim myConn As MySqlConnection = New
MySqlConnection(ConfigurationSettings.AppSettings
("ConnectionString"))
Application("myConnection") = myConn

End Sub
Dim myConn As new MySqlConnection = CType(Application
("myConnection", MySqlConnection))

Dim query As String = "SELECT * FROM users WHERE
username='" & strUserName & "' AND usrPassword=PASSWORD
('" & strPassword & "')"

Dim myCommand As New MySqlCommand(query, myConn)
myConn.Open()
Nov 17 '05 #1
4 1295
The problem is that 2 simultaneous requests are going to grab the same
connection and you will have a problem.
So you need some sort of locking mechanism. Also your design will fail if
MYSQL server will close the connection (server was stopped for maintenance
for example). Then you APP will fail each time even if MYSQL is back and
working fine.

So I think you will be better of with opening connection every time.
And hopping that the pooling will be fixed someday. (Never used MYSQL but
also never heard complains about it's pooling.).

George.

"yop" <yo*@oceanfree.net> wrote in message
news:0d****************************@phx.gbl...
All

I need to store a connection in the application object
due to the need to use MYSQL and its very poor connection
pooling.

Would someone have an example as the code below is not
working correctly.

Thanks

Sub Application_Start(ByVal sender As Object, ByVal e As
EventArgs)
' Fires when the application is started
Dim myConn As MySqlConnection = New
MySqlConnection(ConfigurationSettings.AppSettings
("ConnectionString"))
Application("myConnection") = myConn

End Sub
Dim myConn As new MySqlConnection = CType(Application
("myConnection", MySqlConnection))

Dim query As String = "SELECT * FROM users WHERE
username='" & strUserName & "' AND usrPassword=PASSWORD
('" & strPassword & "')"

Dim myCommand As New MySqlCommand(query, myConn)
myConn.Open()

Nov 17 '05 #2
yop
I do not want to do it this way but due to the pooling
issue, that is more to do with the DbProvider, the
solution I was given was to use a connection in the
application.
MYSQL is fine but there is no good dBProvicder available
at the moment as far I can see. Each one has its problem
or limitations.

thanks
-----Original Message-----
All

I need to store a connection in the application object
due to the need to use MYSQL and its very poor connectionpooling.

Would someone have an example as the code below is not
working correctly.

Thanks

Sub Application_Start(ByVal sender As Object, ByVal e As
EventArgs)
' Fires when the application is started
Dim myConn As MySqlConnection = New
MySqlConnection(ConfigurationSettings.AppSettin gs
("ConnectionString"))
Application("myConnection") = myConn

End Sub
Dim myConn As new MySqlConnection = CType(Application
("myConnection", MySqlConnection))

Dim query As String = "SELECT * FROM users WHERE
username='" & strUserName & "' AND usrPassword=PASSWORD
('" & strPassword & "')"

Dim myCommand As New MySqlCommand(query, myConn)
myConn.Open()
.

Nov 17 '05 #3
MySQL has limitations. It is missing some really neat features. It will get
these features, but it will take time. The pains of open source, I guess.

I will stand behind Kevin 100% on suspecting the person who stated you
should load a connection in Application, however.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

************************************************** **************************
****
Think Outside the Box!
************************************************** **************************
****
"yop" <yo*@oceanfree.net> wrote in message
news:0d****************************@phx.gbl...
I do not want to do it this way but due to the pooling
issue, that is more to do with the DbProvider, the
solution I was given was to use a connection in the
application.
MYSQL is fine but there is no good dBProvicder available
at the moment as far I can see. Each one has its problem
or limitations.

thanks
-----Original Message-----
All

I need to store a connection in the application object
due to the need to use MYSQL and its very poor

connection
pooling.

Would someone have an example as the code below is not
working correctly.

Thanks

Sub Application_Start(ByVal sender As Object, ByVal e As
EventArgs)
' Fires when the application is started
Dim myConn As MySqlConnection = New
MySqlConnection(ConfigurationSettings.AppSettin gs
("ConnectionString"))
Application("myConnection") = myConn

End Sub
Dim myConn As new MySqlConnection = CType(Application
("myConnection", MySqlConnection))

Dim query As String = "SELECT * FROM users WHERE
username='" & strUserName & "' AND usrPassword=PASSWORD
('" & strPassword & "')"

Dim myCommand As New MySqlCommand(query, myConn)
myConn.Open()
.

Nov 17 '05 #4
yop
Believe it or not it was the dBProvider who wrote the
native driver who suggested this! He told me that this
was a MYSQL issue and that the solution he would use was
this!
MY choice was to use SQLServer due to the amounts of
issues I have had with .NET and MYSQL but management
decisions dictate this.

So can I take it that you would suggest the best way to
handle this is to open and close the connection within
each function.

thanks for your help

-----Original Message-----
MySQL has limitations. It is missing some really neat features. It will getthese features, but it will take time. The pains of open source, I guess.
I will stand behind Kevin 100% on suspecting the person who stated youshould load a connection in Application, however.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

************************************************* ******** ***********************
Think Outside the Box!
************************************************* ******** ***********************
"yop" <yo*@oceanfree.net> wrote in message
news:0d****************************@phx.gbl...
I do not want to do it this way but due to the pooling
issue, that is more to do with the DbProvider, the
solution I was given was to use a connection in the
application.
MYSQL is fine but there is no good dBProvicder available at the moment as far I can see. Each one has its problem or limitations.

thanks
>-----Original Message-----
>All
>
>I need to store a connection in the application object
>due to the need to use MYSQL and its very poor

connection
>pooling.
>
>Would someone have an example as the code below is not
>working correctly.
>
>Thanks
>
>Sub Application_Start(ByVal sender As Object, ByVal e As >EventArgs)
> ' Fires when the application is started
> Dim myConn As MySqlConnection = New
>MySqlConnection(ConfigurationSettings.AppSettin gs
>("ConnectionString"))
> Application("myConnection") = myConn
>
>End Sub
>
>
> Dim myConn As new MySqlConnection = CType (Application >("myConnection", MySqlConnection))
>
>Dim query As String = "SELECT * FROM users WHERE
>username='" & strUserName & "' AND usrPassword=PASSWORD >('" & strPassword & "')"
>
>Dim myCommand As New MySqlCommand(query, myConn)
> myConn.Open()
>.
>

.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mark Hoagland | last post by:
I've got a scenario with a web application where I must access the virtual directory being accessed from within the Application_OnStart event handler. Specifically, I have a series of IIS virtual...
1
by: fruddy | last post by:
Hi everyone, Just wanted to ask about Application_OnStart in the global.asa. Now if I request one page from a particular site when I first go to that site say mysite.com/default.asp that triggers...
7
by: Mike D | last post by:
What are the best practices when using a db and include files? I typically store my connection string in an include file. I then open my db do what I need to and close the connection. I haven't...
5
by: Brian Piotrowski | last post by:
Hi All, I almost have the connection working for my connection to the AS/400 from an ASP page. However, I have an error appearing, and I'm not sure how to fix it. The code I have for...
3
by: F C | last post by:
Hello, I would like to find the virtual directory name from within Application_onStart in global.asa. I am in ASP, not ASPX. I have no server.AppPath. Thanks for your help. François.
19
by: Shiv Kumar | last post by:
I see that the Application_OnStart event is fired only once for a certain application. I'm interested in creating a "global" object (an object that will be available to all requests for the...
8
by: Marek | last post by:
Hi, Is Application_OnStart event hadler guaranteed to finish its execution before another HttpApplication object is brought into life? Marek
9
by: Chris | last post by:
where is the best place to put the connection string for use through-out my app? right now I use, in every page/sub/etc: SqlConnect = New SqlConnection("Server=xxxx;uid=xxx;pwd=xxxx;database=xxx")...
2
by: MasterChief | last post by:
I have a OLEDB Connection String that is working very well for me. My question is that I read that you can store the Connection String in a seperate include file or somewhere else. I am just...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.