Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / January 2005



Tip: Looking for answers? Try searching our database.

How the connection Work?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AndrwChau - 16 Sep 2004 05:11 GMT
I just try to create a system under the VB .net with teh ADO .net. I found
that i need to create a sqlconnection in each form. They all have the same
connection string (connect to the same database). Is any way to create one
connection and it work for all form?
Signature

Andrew

Val Mazur - 18 Sep 2004 03:42 GMT
Hi,

If you will write your own code, not use data controls, then you could
declare your connection in a module or class as a public and use it
everywhere in your code.

Signature

Val Mazur
Microsoft MVP

>I just try to create a system under the VB .net with teh ADO .net. I found
> that i need to create a sqlconnection in each form. They all have the same
> connection string (connect to the same database). Is any way to create one
> connection and it work for all form?
Sam - 23 Sep 2004 14:02 GMT
From a performance point of view, is it better to open and close a new
connection each time a query is run in the database?

I have a VB6 program that runs many queries on a database. Now I open
and close a connectioin each time a want to perform a query. Would it
be better to just open one connection, keep this one open all the time
and then use that connection object?

Regards, Sam

> Hi,
>
[quoted text clipped - 6 lines]
> > connection string (connect to the same database). Is any way to create one
> > connection and it work for all form?
Val Mazur - 24 Sep 2004 03:07 GMT
Hi,

From design point of view it is better to open connection, get data or do
some staff and close connection as soon as possible. From performance point
of view you will not lose much, because ADO maintains connection pooling and
if you use exact same connection string each time when you connect to the
database, than it basically takes no time to open connection after
application did it first time. Exact same idea was implemented in ADO.NET
technology

Signature

Val Mazur
Microsoft MVP

> From a performance point of view, is it better to open and close a new
> connection each time a query is run in the database?
[quoted text clipped - 19 lines]
>> > one
>> > connection and it work for all form?
Sam - 27 Sep 2004 08:55 GMT
I do use the same connection string, so I'll leave it as it is and
"open-and-close" the connection each time I need data from the
database.

Thanks for the input

Regards, Sam

> Hi,
>
[quoted text clipped - 29 lines]
> >> > one
> >> > connection and it work for all form?
L Mehl - 30 Jan 2005 19:14 GMT
Val --

I am new at this kind of programming.

Can you suggest the source for a sample of code to write a module or class,
and using it?

Thanks for any help.

Larry

> Hi,
>
[quoted text clipped - 12 lines]
> > --
> > Andrew
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.