Pregunta: | 27681 - CONEXION REMOTA CON ORACLE |
Autor: | Moises Pinto |
Deseo saber si existen API's para conexion de aplicaciones en Visual Basic con Base de Datos Remotas (ORACLE). y si es necesario el incluir componentes para este efecto. Cuento con un win Proxy 2.1, es necesario el mapear puertos. |
Respuesta: | Leonel Zenil Aguilar |
Pues mira no se si sea lo que quieres pero yo te doy este codigo para conectar VB con ORACLE......
Para hacerlo necesitas: * 3 cajas de texto ("text1") * 4 botones de comando ("Command1") el 1º para ir al inicio de tus datos (nombre "cmd_primero") el 2º para avanzar (nombre "cmd_siguiente") el 3º para retroceder (nombre "cmd_anterior") el 4º para ir al final. (nombre "cmd_ultimo") esto es todo lo que vas a utilizar, por que por el lado de la BD esa bd ya va incluida en ORACLE. ah! y esta pedaso de codigo va en una solo linea, aun que ya esta incluido en la parte de abajo solo es por si ocurre un error cnn.ConnectionString = "Provider=OraOLEDB.Oracle.1;Password=tiger;Persist Security Info=True;User ID=scott" Y SOLO COPIA EL CODIGO DE AQUI EN ADELANTE Y PEGALO EN TU FORMULARIO, PERO ANTES DE PEGARLO BORRA TODO EN CODIGO QUE CONTENGA TU FORMULARIO. Private cnn As Connection Dim rst As ADODB.Recordset Private Sub Mostrar_Datos() Text1.Text = rst.Fields("deptno") Text2.Text = rst.Fields("dname") Text3.Text = rst.Fields("loc") End Sub Private Sub cmd_anterior_Click() rst.MovePrevious cmd_siguiente.Enabled = True If rst.BOF = False Then Call Mostrar_Datos Else MsgBox "Estas en el primer registro" rst.MoveFirst Call Mostrar_Datos End If End Sub Private Sub cmd_primero_Click() rst.MoveFirst Call Mostrar_Datos cmd_anterior.Enabled = False cmd_siguiente.Enabled = True cmd_ultimo.Enabled = True End Sub Private Sub cmd_siguiente_Click() rst.MoveNext cmd_anterior.Enabled = True If rst.EOF = False Then Call Mostrar_Datos Else MsgBox "Se ha llegado al último registro" cmd_siguiente.Enabled = False cmd_ultimo.Enabled = False rst.MoveLast Call Mostrar_Datos End If End Sub Private Sub cmd_ultimo_Click() rst.MoveLast cmd_siguiente.Enabled = False cmd_anterior.Enabled = True Call Mostrar_Datos End Sub Private Sub Form_Load() Set cnn = New ADODB.Connection Set rst = New ADODB.Recordset cnn.ConnectionString = "Provider=OraOLEDB.Oracle.1;Password=tiger;Persist Security Info=True;User ID=scott" cnn.Open rst.Source = "select * from dept" rst.CursorType = adOpenStatic rst.LockType = adLockOptimistic rst.ActiveConnection = cnn rst.Open Call Mostrar_Datos End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) rst.Close Set rst = Nothing cnn.Close Set cnn = Nothing End Sub |