
28/01/2006, 15:29
|
| | Fecha de Ingreso: agosto-2005 Ubicación: Peru-Lima
Mensajes: 225
Antigüedad: 19 años, 8 meses Puntos: 0 | |
Cita:
Iniciado por dark_night holas tengo un problema al realizar la ocnsulta sql en la bd
tengo esto en el form_load
Código:
Const PathBase As String = "Base.mdb"
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
With cnn
.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & PathBase & ";"
.Open
End With
rst.Open "SELECT * FROM Datos", cnn, adOpenDynamic, adLockOptimistic
y esto en la funcion para buscar
Código:
Private Sub ProcesarConsulta()
Dim trs As Recordset
Dim tli As ListItem
Dim Sql As String
Sql = "SELECT * FROM Datos where " & CboBuscar.Text & "='" & TxtBuscar.Text & "' ORDER BY titulo"
Set trs = cnn.Execute(Sql)
With trs
If (.BOF And .EOF) Then
MsgBox "No se encontro el Registro Buscado"
end with
end sub
el problama es k al comensar llamar a la funcion buscar, dice k no coinciden los tipos y me marca la lina del execute ....el problema es k no se porke..e revisado todo y no veo el problema
cualkier ayuda es bienvenida
grax Bueno aki este codigo funciona perfectamente :
Código:
Dim RS As New ADODB.Recordset
Dim CN As New ADODB.Connection
Private Sub Command1_Click()
Dim Sql As String
Sql = "SELECT * FROM CLIENTES where " & Text1.Text & "='" & Text2.Text & "' ORDER BY DOC_ID"
Set RS = CN.Execute(Sql)
If (RS.BOF And RS.EOF) Then
MsgBox "No se encontro el Registro Buscado"
Else
MsgBox "NOMBRE = " & RS!NOMBRES
End If
End Sub
Private Sub Form_Load()
With CN
.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=bd;Data Source=pc"
.Open
End With
RS.Open "SELECT * FROM CLIENTES", CN, adOpenDynamic, adLockOptimistic
End Sub
|