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