473,396 Members | 2,090 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,396 software developers and data experts.

SQLConnection passing w/ user controls

Is better to pass the same SQL connection to all of my user controls.
Should I make a global object for my SQL connection, or is there some other
better choice out there.
Thanks

DG
Nov 21 '05 #1
4 1108
David,

In my opinion is it simpler to make for your datahandling one or more
seperated classes.

The connection is than in that. The only things you are passing than is your
dataset (and what I do at the moment , the commands), the result can than be
error information. However there are a lot of ways to do this.

I hope this gives an idea

Cor

"David Gilbert" <da***@NOSPAM.cfsmortgage.com> schreef in bericht
news:eg**************@TK2MSFTNGP10.phx.gbl...
Is better to pass the same SQL connection to all of my user controls.
Should I make a global object for my SQL connection, or is there some
other better choice out there.
Thanks

DG

Nov 21 '05 #2
Ok just to put this in my own terms....

Create a class that has the instructions for my SQL connection and then open
and close, from there. This way If I change the Connection string, its only
in one place.

Thanks>...

DG
..... And the light bulb goes 'Click'
"Cor Ligthert" <no************@planet.nl> wrote in message
news:eF**************@TK2MSFTNGP09.phx.gbl...
David,

In my opinion is it simpler to make for your datahandling one or more
seperated classes.

The connection is than in that. The only things you are passing than is
your dataset (and what I do at the moment , the commands), the result can
than be error information. However there are a lot of ways to do this.

I hope this gives an idea

Cor

"David Gilbert" <da***@NOSPAM.cfsmortgage.com> schreef in bericht
news:eg**************@TK2MSFTNGP10.phx.gbl...
Is better to pass the same SQL connection to all of my user controls.
Should I make a global object for my SQL connection, or is there some
other better choice out there.
Thanks

DG


Nov 21 '05 #3
Ok last question on this...

Know of any good books/websites on Classes?

"David Gilbert" <da***@NOSPAM.cfsmortgage.com> wrote in message
news:ec****************@TK2MSFTNGP12.phx.gbl...
Ok just to put this in my own terms....

Create a class that has the instructions for my SQL connection and then
open and close, from there. This way If I change the Connection string,
its only in one place.

Thanks>...

DG
.... And the light bulb goes 'Click'
"Cor Ligthert" <no************@planet.nl> wrote in message
news:eF**************@TK2MSFTNGP09.phx.gbl...
David,

In my opinion is it simpler to make for your datahandling one or more
seperated classes.

The connection is than in that. The only things you are passing than is
your dataset (and what I do at the moment , the commands), the result can
than be error information. However there are a lot of ways to do this.

I hope this gives an idea

Cor

"David Gilbert" <da***@NOSPAM.cfsmortgage.com> schreef in bericht
news:eg**************@TK2MSFTNGP10.phx.gbl...
Is better to pass the same SQL connection to all of my user controls.
Should I make a global object for my SQL connection, or is there some
other better choice out there.
Thanks

DG



Nov 21 '05 #4
David,
Ok just to put this in my own terms....

Create a class that has the instructions for my SQL connection and then
open and close, from there. This way If I change the Connection string,
its only in one place.

No opening and closing is an unimportant part. When you use a dataadapter it
is even not needed.

However a sample, mostly typed, so watch typos or other things I typed
wrong.

\\\
Public Class DataClass
Public Function selectDS(mydataset, selectstring) As String
Dim frmSplash As New frmSplash
frmStatusMessage.Show("Connecting to SQL Server")
Dim conn As New SqlConnection(connString)
Try
Dim cmd As New SqlCommand (selectstring, conn)
da = New SqlDataAdapter(cmd)
dsMessages = New DataSet
da.Fill(mydataset)
Return ""
catch sqlExc As SqlException
return(sqlExc.ToString)
Catch ex As Exception
return(exc.Message)
Finally
conn.Close()
frmSplash.Close()
End Try
End Function
End Class
///

When you want it shared than the only thing that changes is
\\\
Public Shared Function selectDS(mydataset, selectstring) As String
///

I hope this gives some ideas

Cor
Nov 21 '05 #5

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

Similar topics

11
by: Bob | last post by:
In our new .NET web applications, we try to limit the use of SqlConnection to just one instance per page, even if there are multiple accesses to various queries. The thinking behind is that this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.