|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Class Instantiationand perform any and all ADO.NET database activities. This is an MDI child based application where the child forms are in an MDI tabbed environment. So when a new MDI child form is displayed, a new tab is created much like VS.NET 2005 development environment. Is it best to dimension a new SQL wrapper class at the module level of a child form, or should I be creating a new class in every function that accesses the database? If done at the function level, in theory, the class is instantiated, used and then released for garbage collection when the function terminates. As opposed to creating a new wrapper class at the module level and using that variable in all the functions that access the database. This would keep the class in memory until the child form is closed. There may be many functions (10-15) within a given child form that access the database. So should there be a Dim Myconn as New SQLWrapperClass in every function or is it better to create the class once at the module level? Thanks, -- Scott H. I have a similiar application and instantiate the Database access class in a
module so I can use it in all classes. I probalby will get "Flamed" for this and if you don't want to do this, you can make all properties and methods shared in the class. This way, you won't have instantiate the class as a global. -- Show quoteHide quoteDennis in Houston "Scott H." wrote: > I have aVB.NET application that uses an SQL Server wrapper class to connect > and perform any and all ADO.NET database activities. This is an MDI child > based application where the child forms are in an MDI tabbed environment. So > when a new MDI child form is displayed, a new tab is created much like VS.NET > 2005 development environment. > > Is it best to dimension a new SQL wrapper class at the module level of a > child form, or should I be creating a new class in every function that > accesses the database? If done at the function level, in theory, the class is > instantiated, used and then released for garbage collection when the function > terminates. As opposed to creating a new wrapper class at the module level > and using that variable in all the functions that access the database. This > would keep the class in memory until the child form is closed. > > There may be many functions (10-15) within a given child form that access > the database. So should there be a Dim Myconn as New SQLWrapperClass in > every function or is it better to create the class once at the module level? > > Thanks, > -- > Scott H. So I could create a global reference to the SQL wrapper class, something like
this: Module Generic Public MyConn as New SQLWrapper End Module And then use Myconn as a global variable throughout the application. Sounds like a interesting idea. Is this generally a good practice? -- Show quoteHide quoteScott H. "Dennis" wrote: > I have a similiar application and instantiate the Database access class in a > module so I can use it in all classes. I probalby will get "Flamed" for this > and if you don't want to do this, you can make all properties and methods > shared in the class. This way, you won't have instantiate the class as a > global. > -- > Dennis in Houston > > > "Scott H." wrote: > > > I have aVB.NET application that uses an SQL Server wrapper class to connect > > and perform any and all ADO.NET database activities. This is an MDI child > > based application where the child forms are in an MDI tabbed environment. So > > when a new MDI child form is displayed, a new tab is created much like VS.NET > > 2005 development environment. > > > > Is it best to dimension a new SQL wrapper class at the module level of a > > child form, or should I be creating a new class in every function that > > accesses the database? If done at the function level, in theory, the class is > > instantiated, used and then released for garbage collection when the function > > terminates. As opposed to creating a new wrapper class at the module level > > and using that variable in all the functions that access the database. This > > would keep the class in memory until the child form is closed. > > > > There may be many functions (10-15) within a given child form that access > > the database. So should there be a Dim Myconn as New SQLWrapperClass in > > every function or is it better to create the class once at the module level? > > > > Thanks, > > -- > > Scott H. Yes that works. If you want to use the shared technique then;
public Class SQLWrapper Shared property .... Shared method .... end Class Then when used in your other classes, etc; SqlWrapper.property = .... SqlWrapper does not need to be instantiated. -- Show quoteHide quoteDennis in Houston "Scott H." wrote: > So I could create a global reference to the SQL wrapper class, something like > this: > > Module Generic > Public MyConn as New SQLWrapper > End Module > > And then use Myconn as a global variable throughout the application. Sounds > like a interesting idea. Is this generally a good practice? > -- > Scott H. > > > "Dennis" wrote: > > > I have a similiar application and instantiate the Database access class in a > > module so I can use it in all classes. I probalby will get "Flamed" for this > > and if you don't want to do this, you can make all properties and methods > > shared in the class. This way, you won't have instantiate the class as a > > global. > > -- > > Dennis in Houston > > > > > > "Scott H." wrote: > > > > > I have aVB.NET application that uses an SQL Server wrapper class to connect > > > and perform any and all ADO.NET database activities. This is an MDI child > > > based application where the child forms are in an MDI tabbed environment. So > > > when a new MDI child form is displayed, a new tab is created much like VS.NET > > > 2005 development environment. > > > > > > Is it best to dimension a new SQL wrapper class at the module level of a > > > child form, or should I be creating a new class in every function that > > > accesses the database? If done at the function level, in theory, the class is > > > instantiated, used and then released for garbage collection when the function > > > terminates. As opposed to creating a new wrapper class at the module level > > > and using that variable in all the functions that access the database. This > > > would keep the class in memory until the child form is closed. > > > > > > There may be many functions (10-15) within a given child form that access > > > the database. So should there be a Dim Myconn as New SQLWrapperClass in > > > every function or is it better to create the class once at the module level? > > > > > > Thanks, > > > -- > > > Scott H.
SQL query on Datatables [VB 2005]
Datagridview cell background color? simple thread question arraylist to use in another form Disable objectdatasource-control Drawing a square (or circles) before each item of a treeview Textbox Click Event needed. 'System.Security.SecurityException' with .NET 2005 Only Creating Multiple Listviews in Code Validating Data in a DataGrid |
|||||||||||||||||||||||