como conectar una base de datos hecha en sql server 2000 en visual basic 6.0 con codigo
como puedo conectar una base de datos sql server 2000 mediante codigo atraves de visula basic 6.0
Option Explicit
'DECLARACION DE UN VARIABLE OBJETO DEL TIPO ADODB.CONNECTION
Public con_conexion As ADODB.Connection
Public rec_conexion As ADODB.Recordset
Public Sub ConectarBD()
'On Error GoTo error:
'SE INSTANCIA EL OBJETO CON DEL TIPO CONNECTION
Set con_conexion = New ADODB.Connection
'CONFIGURACION DEL CON_AUTO
con_conexion.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog= TuBASEdeDAtos"
'SE ABRE LA CONEXION
con_conexion.Open
'error:
' If Err.Number > 0 Then
' Err.Description
' Resume Next
' End If
End Sub
Public Sub DesconectarBD()
'SE CIERRA LA CONEXION
con_conexion.Close
'LIBERAR MEMORIA
Set con_conexion = Nothing
End Sub
Public Sub Ejecutar(strsql As String)
' On Error GoTo error:
Set rec_conexion = New ADODB.Recordset
rec_conexion.CursorLocation = adUseClient
rec_conexion.Open strsql, con_conexion
'error:
' If Err.Number > 0 Then
' MsgBox Err.Description
' Resume Next
'End If
End Sub
'DECLARACION DE UN VARIABLE OBJETO DEL TIPO ADODB.CONNECTION
Public con_conexion As ADODB.Connection
Public rec_conexion As ADODB.Recordset
Public Sub ConectarBD()
'On Error GoTo error:
'SE INSTANCIA EL OBJETO CON DEL TIPO CONNECTION
Set con_conexion = New ADODB.Connection
'CONFIGURACION DEL CON_AUTO
con_conexion.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog= TuBASEdeDAtos"
'SE ABRE LA CONEXION
con_conexion.Open
'error:
' If Err.Number > 0 Then
' Err.Description
' Resume Next
' End If
End Sub
Public Sub DesconectarBD()
'SE CIERRA LA CONEXION
con_conexion.Close
'LIBERAR MEMORIA
Set con_conexion = Nothing
End Sub
Public Sub Ejecutar(strsql As String)
' On Error GoTo error:
Set rec_conexion = New ADODB.Recordset
rec_conexion.CursorLocation = adUseClient
rec_conexion.Open strsql, con_conexion
'error:
' If Err.Number > 0 Then
' MsgBox Err.Description
' Resume Next
'End If
End Sub
