Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Aug 19, 2017 12:38 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Doubt, is necessary repeat string connect in all page?
PostPosted: Sun May 19, 2013 12:01 pm 
Offline

Joined: Sat Jun 11, 2011 8:46 pm
Posts: 33
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Doubt, is necessary repeat string connect in all page?
PostPosted: Sun May 19, 2013 1:22 pm 
Offline

Joined: Wed Mar 22, 2006 11:15 am
Posts: 712
Location: Southern California
Each session should have a db connection. Store db in the Session object.

_________________
Daniel L. Taylor
Custom Controls for Real Studio WE!
Visit: http://www.webcustomcontrols.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Doubt, is necessary repeat string connect in all page?
PostPosted: Sun May 19, 2013 1:49 pm 
Offline

Joined: Sat Jun 11, 2011 8:46 pm
Posts: 33
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Doubt, is necessary repeat string connect in all page?
PostPosted: Sun May 19, 2013 2:53 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Doubt, is necessary repeat string connect in all page?
PostPosted: Sun May 19, 2013 4:49 pm 
Offline

Joined: Wed Mar 22, 2006 11:15 am
Posts: 712
Location: Southern California
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.

_________________
Daniel L. Taylor
Custom Controls for Real Studio WE!
Visit: http://www.webcustomcontrols.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Doubt, is necessary repeat string connect in all page?
PostPosted: Sun May 19, 2013 7:49 pm 
Offline

Joined: Sat Jun 11, 2011 8:46 pm
Posts: 33
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group