Código:
Gracias y un saludo. Imports System.Data.SqlClient Public Class datos Private con As SqlConnection Public Sub New() con.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings("constring") End Sub Public Sub New(ByVal constring As String) con.ConnectionString = constring End Sub Public Function DevuelveDT(ByVal strSQL As String) As DataTable Dim cmd As New SqlCommand(strSQL, con) Dim dt As New DataTable dt.Clear() Dim da As New SqlDataAdapter(cmd) Try da.Fill(dt) Return dt Catch ex As Exception Finally If con.State.Open = ConnectionState.Open Then con.Close() End If End Try cmd.Dispose() da.Dispose() End Function End Class