Real Software Forums
http://forums.realsoftware.com/

Doubt, is necessary repeat string connect in all page?
http://forums.realsoftware.com/viewtopic.php?f=23&t=47918
Page 1 of 1

Author:  fernandopm [ Sun May 19, 2013 12:01 pm ]
Post subject:  Doubt, is necessary repeat string connect in all page?

I need access for all pages with db mysql, but is necessary repeat string connection in all pages..? :

Dim db As New MySQLCommunityServer
db.Host = "192.168.1.172"
db.Port = 3306
db.DatabaseName = "BaseballLeague"
db.UserName = "broberts"
db.Password = "streborb"
If db.Connect Then
// Use the database
Else
// Connection error
MsgBox(db.ErrorMessage)
End If



in all pages? or is possible use Alias DB?

Author:  taylor-design [ Sun May 19, 2013 1:22 pm ]
Post subject:  Re: Doubt, is necessary repeat string connect in all page?

Each session should have a db connection. Store db in the Session object.

Author:  fernandopm [ Sun May 19, 2013 1:49 pm ]
Post subject:  Re: Doubt, is necessary repeat string connect in all page?

taylor-design wrote:
Each session should have a db connection. Store db in the Session object.


I do not understand, is logic one connection for all users, CGI Application or Standalone running all time,not share connection DB for all?

Author:  timhare [ Sun May 19, 2013 2:53 pm ]
Post subject:  Re: Doubt, is necessary repeat string connect in all page?

Do NOT share the database connection between users. Create a new database object and connection for each session. You can share the connection between web pages for the same connection. That's why you create it in the session object.

Author:  taylor-design [ Sun May 19, 2013 4:49 pm ]
Post subject:  Re: Doubt, is necessary repeat string connect in all page?

fernandopm wrote:
taylor-design wrote:
Each session should have a db connection. Store db in the Session object.


I do not understand, is logic one connection for all users, CGI Application or Standalone running all time,not share connection DB for all?


Multiple users (i.e. sessions) will be accessing the database at the same time. If you use one global connection they will either block each other, or step on each other (i.e. user A seeing error info for a query performed by user B).

If you have a separate connection for each session you let the database manage concurrency issues, which is what databases like Postgres and MySQL are designed to do and do well. You also insure that operations by one user will not alter connection state for another user.

Author:  fernandopm [ Sun May 19, 2013 7:49 pm ]
Post subject:  Re: Doubt, is necessary repeat string connect in all page?

taylor-design wrote:
fernandopm wrote:
taylor-design wrote:
Each session should have a db connection. Store db in the Session object.


I do not understand, is logic one connection for all users, CGI Application or Standalone running all time,not share connection DB for all?


Multiple users (i.e. sessions) will be accessing the database at the same time. If you use one global connection they will either block each other, or step on each other (i.e. user A seeing error info for a query performed by user B).

If you have a separate connection for each session you let the database manage concurrency issues, which is what databases like Postgres and MySQL are designed to do and do well. You also insure that operations by one user will not alter connection state for another user.


Thank's, Is true

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/