46 lines
1.4 KiB
VB.net
46 lines
1.4 KiB
VB.net
Imports System.Data.SqlClient
|
|
|
|
|
|
Namespace ExecConexion
|
|
|
|
Public Class ClassCon
|
|
'Declaracion de los instancias de objetos para conectarme a la base de datos
|
|
Public Indice As Integer 'indice de la lista o combo
|
|
Public cnString As String 'cadena de conexiòn de la BD
|
|
Public lsSQL As String 'declaracion de datagrid
|
|
Public cn As New SqlClient.SqlConnection 'declaraciòn de conexiòn a la BD
|
|
|
|
Public Sub ConectaBD(ByVal sAmbienteConexion As String)
|
|
|
|
Try
|
|
'Declaro una instancia dela clase LeeEditorRegistro, la cual me ayuda
|
|
'a recuperar la cadena conexion
|
|
If cn.State = ConnectionState.Closed Then
|
|
Dim Conexion As LeeEditorRegistro = New LeeEditorRegistro
|
|
Dim valor As String
|
|
valor = Conexion.cad(sAmbienteConexion)
|
|
cn.ConnectionString = valor
|
|
cn.Open()
|
|
End If
|
|
Catch ex As Exception
|
|
MessageBox.Show("error en ClsComplejo; ConectaBD: " & ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
End Try
|
|
End Sub
|
|
|
|
Public Sub sbCierraCn()
|
|
'cierra la conexiòn a la BD
|
|
cn.Close()
|
|
End Sub
|
|
|
|
Public Sub New()
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub Finalize()
|
|
MyBase.Finalize()
|
|
End Sub
|
|
End Class
|
|
|
|
End Namespace
|
|
|