473,408 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

VB.Net and Database Connections

Hi all,

I just started to play around with VB.Net.

I currenlty do Powerbuilder work and was wondering how database connection
management works in VB.net.

My applications typically pop-up a login window, attempts to connect to the
database (Sybase or MSSQL). Once the connection is established, it will open
a MDI Frame and the application will do whatever it is meant to do. (Mostly
reporting by SQL Query...in PB there is something called the Datawindow)

In Powerbuilder, there is a "global" variable called SQLCA which holds the
connection to the database and is accessible from any point in the
application given its global nature.

For instance, to connect to the database, I will set properties for the
SQLCA object then issue the following command:

connect using SQLCA;

then wherever I am in the application, I can reference the SQLCA object for
a valid database connection.

How is something like this done in VB.Net.
I managed to create a login window. I have the connection logic in the
clicked event of the OK button and it does connect to MS SQLServer 2K. Do I
have to then Pass the connection object to the MDI frame and other child
windows etc?

Or is there a cleaner way to do this?
I don't know if declaring a global oledbconnection object is the correct
thing to do.

Please advise!
Thanks
Nick

Nov 20 '05 #1
10 1694
Shared Variables work...
"Nick N." <ni************@natexisblr.us> wrote in message
news:OG**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I just started to play around with VB.Net.

I currenlty do Powerbuilder work and was wondering how database connection
management works in VB.net.

My applications typically pop-up a login window, attempts to connect to the database (Sybase or MSSQL). Once the connection is established, it will open a MDI Frame and the application will do whatever it is meant to do. (Mostly reporting by SQL Query...in PB there is something called the Datawindow)

In Powerbuilder, there is a "global" variable called SQLCA which holds the
connection to the database and is accessible from any point in the
application given its global nature.

For instance, to connect to the database, I will set properties for the
SQLCA object then issue the following command:

connect using SQLCA;

then wherever I am in the application, I can reference the SQLCA object for a valid database connection.

How is something like this done in VB.Net.
I managed to create a login window. I have the connection logic in the
clicked event of the OK button and it does connect to MS SQLServer 2K. Do I have to then Pass the connection object to the MDI frame and other child
windows etc?

Or is there a cleaner way to do this?
I don't know if declaring a global oledbconnection object is the correct
thing to do.

Please advise!
Thanks
Nick

Nov 20 '05 #2
* "Nick N." <ni************@natexisblr.us> scripsit:
I currenlty do Powerbuilder work and was wondering how database connection
management works in VB.net.

My applications typically pop-up a login window, attempts to connect to the
database (Sybase or MSSQL). Once the connection is established, it will open
a MDI Frame and the application will do whatever it is meant to do. (Mostly
reporting by SQL Query...in PB there is something called the Datawindow)


This is a VB.NET language group. Notice that you will have a better
chance to get an answer if you post to the ADO.NET newsgroup in future:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microso ft.public.dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Excuse me there man.
You act like I stepped on dog crap and stepped into your car or something.

S-E-N-S-T-I-V-E

Take it easy will ya?
Take some prozac and call me in the morning.

I heyt 4kin G33ks liek u.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bp*************@ID-208219.news.uni-berlin.de...
* "Nick N." <ni************@natexisblr.us> scripsit:
I currenlty do Powerbuilder work and was wondering how database connection management works in VB.net.

My applications typically pop-up a login window, attempts to connect to the database (Sybase or MSSQL). Once the connection is established, it will open a MDI Frame and the application will do whatever it is meant to do. (Mostly reporting by SQL Query...in PB there is something called the Datawindow)
This is a VB.NET language group. Notice that you will have a better
chance to get an answer if you post to the ADO.NET newsgroup in future:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups...ups/loadframes
..asp?icp=msdn&slcid=us&newsgroup=microsoft.public .dotnet.framework.adonet>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4
"Nick N." <ni************@natexisblr.us> wrote...
I managed to create a login window. I have the connection logic in the
clicked event of the OK button and it does connect to MS SQLServer 2K. Do I have to then Pass the connection object to the MDI frame and other child
windows etc?

Or is there a cleaner way to do this?
I don't know if declaring a global oledbconnection object is the correct
thing to do.


Hi Nick... First I for one don't think you'd get a better response in
ADO.NET... there would surely be a traffic cop there telling you to post in
dotnet.languages.vb :-)

Now... in .Net you typically don't keep the connection open. So you could
can create a connection as you need it or create a class that contains your
connection information. If you make the methods "shared" you don't have to
instantiate an object to reference those methods.

You'll create the connection, open the connection, fetch the data, close the
connection.

Tom
Nov 20 '05 #5
> Excuse me there man.
You act like I stepped on dog crap and stepped into your car or something.

S-E-N-S-T-I-V-E
1) There was nothing rude about that comment. You just kinda have to know
herfried, if he says something thats short and to the point, its more than
likely its been answered about 1000 times here and thats pretty much just
cut and copied text (because we've all seen it before)

2) I heyt 4kin G33ks liek u.

No l33t talk in here... 1994 called, they wan't there lingo back...

Take it easy will ya?
Take some prozac and call me in the morning.

I heyt 4kin G33ks liek u.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bp*************@ID-208219.news.uni-berlin.de...
* "Nick N." <ni************@natexisblr.us> scripsit:
I currenlty do Powerbuilder work and was wondering how database connection management works in VB.net.

My applications typically pop-up a login window, attempts to connect
to
the database (Sybase or MSSQL). Once the connection is established, it
will
open a MDI Frame and the application will do whatever it is meant to do. (Mostly reporting by SQL Query...in PB there is something called the
Datawindow)
This is a VB.NET language group. Notice that you will have a better
chance to get an answer if you post to the ADO.NET newsgroup in future:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups...ups/loadframes .asp?icp=msdn&slcid=us&newsgroup=microsoft.public. dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


Nov 20 '05 #6
No, I don't know Herfried, so I did take offense to that...whatever man.
I double posted by mistake (stupid outlook express) and was the first to
point that out.

Nice, real nice...

get some sun once in a while.
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:vs************@corp.supernews.com...
Excuse me there man.
You act like I stepped on dog crap and stepped into your car or something.

S-E-N-S-T-I-V-E
1) There was nothing rude about that comment. You just kinda have to

know herfried, if he says something thats short and to the point, its more than
likely its been answered about 1000 times here and thats pretty much just
cut and copied text (because we've all seen it before)

2) I heyt 4kin G33ks liek u.

No l33t talk in here... 1994 called, they wan't there lingo back...

Take it easy will ya?
Take some prozac and call me in the morning.

I heyt 4kin G33ks liek u.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bp*************@ID-208219.news.uni-berlin.de...
* "Nick N." <ni************@natexisblr.us> scripsit:
> I currenlty do Powerbuilder work and was wondering how database

connection
> management works in VB.net.
>
> My applications typically pop-up a login window, attempts to connect to
the
> database (Sybase or MSSQL). Once the connection is established, it

will
open
> a MDI Frame and the application will do whatever it is meant to do.

(Mostly
> reporting by SQL Query...in PB there is something called the

Datawindow)
This is a VB.NET language group. Notice that you will have a better
chance to get an answer if you post to the ADO.NET newsgroup in future:
<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups...ups/loadframes ..asp?icp=msdn&slcid=us&newsgroup=microsoft.public .dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>



Nov 20 '05 #7
Cor
Hi Nick,

Good to see your back, why did you post this also in the Ado.net group? No
friends here? I would normaly not add to Tom Leylan, but because it's you I
do that of course and I can add something.

I know nothing about those databases you told about, but one of the special
thing from Ado.Net is what Tom already told you closing the connections.
Just think on internet when you work with Ado.net than all things become
suddenly clear.

The best way to use that is to get good selected portions of data on the
client using the datasets. Process it there and then send only the changes
back to the server for processing. (A standard feature of the dataset).

But I there are also so called datareaders and datawriters and more of that
stuff with that you keep your connections open. They use the same commands
but not the dataAdapter and the dataset.

And for I forget when you start with datasets, don't forget to look to the
commandbuilder. Most examples from Microsoft are made with SQL while you
normaly only need a good written "Select" statement. The commandbuilder
makes than all the "Update", "Delete" and "Inserts" for you.

Cor

Nov 20 '05 #8
On Mon, 24 Nov 2003 15:47:29 -0500, Tom Leylan wrote:

You'll create the connection, open the connection, fetch the data, close the
connection.

Tom


To add to Tom's answer, ADO.NET pools connections by default so there is
normally no issue with opening a connection and closing it as Tom
suggested. If the connection is opened with the same connection string
within 60 seconds (default) it will just reuse a connnection from the
connection pool.
--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #9
* "Nick N." <ni************@natexisblr.us> scripsit:
No, I don't know Herfried, so I did take offense to that...whatever man.
I double posted by mistake (stupid outlook express) and was the first to
point that out.

Nice, real nice...

get some sun once in a while.


Sorry for that... It was not my intention to be rude.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #10
That's a big relief.
I never intended to offend anyone.
I'm just looking for some honest help from people (like yourself) who can
offer some good advise for the newbie.

Thanks!
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bp*************@ID-208219.news.uni-berlin.de...
* "Nick N." <ni************@natexisblr.us> scripsit:
No, I don't know Herfried, so I did take offense to that...whatever man.
I double posted by mistake (stupid outlook express) and was the first to
point that out.

Nice, real nice...

get some sun once in a while.


Sorry for that... It was not my intention to be rude.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
4
by: dustin lee | last post by:
Over the years I've gotten out of the habit of explicitly closing file objects (whether for reading or writing) since the right thing always seems to happen auto-magically (e.g. files get written...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
4
by: Sierra | last post by:
Problem: Database connections are not being reused properly. SP_WHO2 shows upwards of 200 connections being created per page request. Most connections exist for 60 seconds then close without...
7
by: Martin | last post by:
Hello Does anyone know if it is possible to use the smo db.Create() method to create a new sql server database with sql server 2005 express? The debugger complains that remote operations are not...
5
by: John | last post by:
I have an ASP.NET 2.0 application developed in VB.net, that accesses an Microsoft Access database. When the database is on the same IIS server all works just fine. BUT when it tried to access the...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
8
by: BD | last post by:
I am developing C# win form app to work with remote database on SQL Server 2005. Problem scenario is as follows: 1. a form is open that has downloaded dataset to local cache 2. computer is...
9
by: Gordon | last post by:
I want to add a feature to a project I'm working on where i have multiple users set up on my Postgres database with varying levels of access. At the bare minimum there will be a login user who...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.