como hacer la conexion manualmente

D.MARADONA
18 de Febrero del 2004
Hola pueden decirme como puedo hacer la conexion mediante un ADO en este caso adodc1, mediante código y tambien mediante código enlazar los textbox que se necesiten a cada campo de la tabla que esté conectada al ADO ( todo esto mediante código).

CristianballZ
18 de Febrero del 2004
Option Explicit

'DECLARACION DE UN VARIABLE OBJETO DEL TIPO ADODB.CONNECTION
Public CON_conexion As ADODB.Connection
Public rec_Recorset As ADODB.Recordset


Public Sub ConectarBD()
'On Error GoTo error:
'SE INSTANCIA EL OBJETO CON AUTO 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=Cocina"

'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_Recorset = New ADODB.Recordset
rec_Recorset.CursorLocation = adUseClient
rec_Recorset.Open strsql, CON_conexion
'error:
' If Err.Number > 0 Then
' MsgBox Err.Description
' Resume Next
'End If
End Sub
y para llenar las text

text1text=rec_recorset("field")
si necesitas más ayuda te envio un ejemplo

llanes
18 de Febrero del 2004
cuando trato de crear

'DECLARACION DE UN VARIABLE OBJETO DEL TIPO
ADODB.CONNECTION

Public CON_conexion As ADODB.Connection
Public rec_Recorset As ADODB.Recordset

no me deja poner el ADODB.connection , me puede decir porque es que sea esto quizas necesite el service pack 4 o algo así