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




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com