.NETGURU
instanciate a sqlconnection array
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-sqlclient' list.


David Winslow
-- Moved from [aspngdata] to [ngfx-sqlclient] by Marcie Jones <Click here to reveal e-mail address> --

-- Moved from [aspngfreeforall] to [aspngdata] by Tim Musschoot <Click here to reveal e-mail address> --

Hey,

I have got a data access class where I need to have some connections
available. Is there a better way to instantiate this array than looping
trough each element in my array (vb or c#)?

Code
======

    Dim mConnectionString As String
Private Connection(10) As SqlConnection
Public Sub New(ByVal sconn As String)
mConnectionString = sconn
Try
Dim i As Integer
For i = 0 To Connection.Length - 1
Connection(i) = New SqlConnection()
Next
Catch exp As Exception
End Try
End Sub

Reply to this message...
 
    
James Avery
Looks like it would work, but do you need to have them in an array? It
seems like it would be easier to keep track and close if you used them
as separate objects. You should also have a Try around the
Connection(i) = New SqlConnection() otherwise if there is an error you
would be leave all the prior connections open.

-----Original Message-----
From: David Winslow [mailto:Click here to reveal e-mail address]
Sent: Friday, July 19, 2002 3:58 AM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] instanciate a sqlconnection array

-- Moved from [aspngdata] to [ngfx-sqlclient] by Marcie Jones
<Click here to reveal e-mail address> --

-- Moved from [aspngfreeforall] to [aspngdata] by Tim Musschoot
<Click here to reveal e-mail address> --

Hey,

I have got a data access class where I need to have some connections
available. Is there a better way to instantiate this array than looping
trough each element in my array (vb or c#)?

Code
======

    Dim mConnectionString As String
Private Connection(10) As SqlConnection
Public Sub New(ByVal sconn As String)
mConnectionString = sconn
Try
Dim i As Integer
For i = 0 To Connection.Length - 1
Connection(i) = New SqlConnection()
Next
Catch exp As Exception
End Try
End Sub

| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT

Reply to this message...
 
 
System.Data.SqlClient.SqlConnection




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification