Andre’s Weblog

conexion visual basic 6 con sql server

Private Sub conexion()

On Error GoTo error
‘ Por si ya estaba abierta…
Set cnn = Nothing

‘ Crear los objetos
Set cnn = New ADODB.Connection

servidor = txtServidor.Text
base = txtBase.Text

‘ abrir la base usando las credenciales de Windows
cnn.Open “Provider=SQLOLEDB; ” & _
“Initial Catalog=” & txtBase.Text & “; ” & _
“Data Source=” & txtServidor.Text & “; ” & _
“integrated security=SSPI; persist security info=True;”

lblpassword.Caption = ” Conexion Establecida “

Exit Sub
error:
MsgBox Err.Description, vbInformation, Err.Number
End
End Sub

Escribe un comentario