Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaring object in module (multi user application) 1

Status
Not open for further replies.

StylizIT

Programmer
Dec 4, 2003
62
NL
hi people, Is it a good thnig to declare objects, like datareaders, odbccommand obejcts, etc in a module for public use in a multi user application, or is it better to declare them and then add them to a users session?

- is it also a good idea to declare 1 odbccommand, datareader etc. and then change the commandtext constantly? cause I don't see why it should be a problem.

Somehow I think the way I'm using those objects is the root to all of the problems I'm encountering right now



You can better regret that you have done something than regret the fact you done nothing
 
It is not a good idea to declare objects in a Module because then ALL users use the same object, many times at the same time. A module is basically a Class whose members all have the Shared modifier. Using Shared in an ASP environment means all users access the same variables...not a good idea unless the dat must be truly shared and then you need to use Synclock or Monitor to prevent simultaneous update.

Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
thanks for your reply m8, glad you straigtened that up for me. Gonna make some major changes to my application and test again to see if I get errors.

Another thing: I am using one open databse connection troughout my whole application. Is it better to open and close the connection everytime it need's to access the database, or is it better to just leave it open all the time? Cause that also might be something that's causing problems.

thanks in advance

You can better regret that you have done something than regret the fact you done nothing
 
Open at the last moment and Close at the first opporunity. Use Dynamic Help in VS. Get Indfex and Type in Connection. You will see an entry for about Connection objects. The Help is full of interesting reading.

"The following topics provide information about how to create and manage ADO.NET connection objects in Visual Studio.

In This Section
Introduction to ADO.NET Connection Design Tools
Provides an overview of connection objects and how to work with them.
Creating ADO.NET Connection Objects
Explains how to create connection objects on forms and components.
Creating Connections to SQL Server
Explains how to establish a connection between an application and a SQL Server database.
Creating Connections to Access Databases
Explains how to establish a connection between an application and a Microsoft Access database.
Creating Connections to ODBC Data Sources
Explains how to establish a connection between an application and an ODBC data source.
Creating Connections to Oracle Databases
Explains how to establish a connection between an application and an Oracle database.
Related Sections
Adding New Data Connections in Server Explorer
Explains how to create design-time connections in Visual Studio, which you can use to browse available data sources.
Connecting to a Data Source Using ADO.NET
Lists topics in the .NET Framework documentation that describes how to create and manage connection objects programmatically.
Configuring Applications Using Dynamic Properties
Provides conceptual information about storing property values in a configuration file that can be changed at run time, which is particularly useful for connection information such as server name and user name.
Connection Pooling for the .Net Data Provider for SQL Server
Provides instructions on how to manually manage connection pooling if you are using the SqlConnection class. "


Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
thanks m8

You can better regret that you have done something than regret the fact you done nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top