1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
Dim cn As New SqlConnection(My.Settings.Conn_DB) cn.Open() 'DataAdapter will open the connection so this is not needed. Dim SqlAttr As New SqlDataAdapter Dim ds As New DataSet Dim sqlcmd As New SqlCommand With sqlcmd .Connection = cn .CommandType = CommandType.StoredProcedure .CommandText = sql End With SqlAttr.SelectCommand = sqlcmd SqlAttr.Fill(ds)