0% found this document useful (0 votes)
34 views3 pages

CCCC CCCC CCCC

This document contains code for connecting to and querying a database called DICCIONARIO.mdb using ADO. It defines several ADODB objects like Connection, Recordset and Fields. It contains methods to open the connection, query different tables, add/update records and close the connection. The tables being queried are Form1, Form2 etc and fields of these tables are accessed and updated.

Uploaded by

danny mesias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views3 pages

CCCC CCCC CCCC

This document contains code for connecting to and querying a database called DICCIONARIO.mdb using ADO. It defines several ADODB objects like Connection, Recordset and Fields. It contains methods to open the connection, query different tables, add/update records and close the connection. The tables being queried are Form1, Form2 etc and fields of these tables are accessed and updated.

Uploaded by

danny mesias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Imports ADODB

Module Module1
Public Conexion As ADODB.Connection
Public caracteristicas As ADODB.Recordset
Public Camposcarac As ADODB.Fields
Public editorial As ADODB.Recordset
Public Camposedit As ADODB.Fields
Public detalle As ADODB.Recordset
Public Camposdeta As ADODB.Fields
Public diccionario As ADODB.Recordset
Public Camposdic As ADODB.Fields
Public idioma As ADODB.Recordset
Public Camposidi As ADODB.Fields
Public tipo As ADODB.Recordset
Public Campostipos As ADODB.Fields
Dim Respuesta As Integer
Public Sub AbrirBase()
Conexion = New ADODB.Connection
Conexion.ConnectionString = "Provider=Microsoft.MSSQL Server;Data
Source=DICCIONARIO.mdb;"
Try
Conexion.Open()
Catch ex As Exception
End Try
Respuesta = Conexion.Errors.Count()
If Respuesta <> 0 Then
MsgBox("ERROR: No se logro la Conexi�n", MsgBoxStyle.Critical, "Error
de Conexi�n")
Else
MsgBox("La Conexi�n Fue Satisfactoria", MsgBoxStyle.Information,"Conexi�n
Establecida")
End If
End Sub
Public Sub AbrirCaracteristicas()
caracteristicas = New ADODB.Recordset
With caracteristicas
.ActiveConnection = Conexion
.CursorType = CursorTypeEnum.adOpenKeyset
.LockType = LockTypeEnum.adLockOptimistic
.Open("Select*from Form1")
End With
End Sub
Public Sub AbrirEditorial()
editorial = New ADODB.Recordset
With editorial
.ActiveConnection = Conexion
.CursorType = CursorTypeEnum.adOpenKeyset
.LockType = LockTypeEnum.adLockOptimistic
.Open("Select*from Form2")
End With
End Sub
Public Sub AbrirIdioma()
idioma = New ADODB.Recordset
With idioma
.ActiveConnection = Conexion
.CursorType = CursorTypeEnum.adOpenKeyset
.LockType = LockTypeEnum.adLockOptimistic
.Open("Select*from Form3")
End With
End Sub
Public Sub AbrirDetalle()
detalle = New ADODB.Recordset
With detalle
.ActiveConnection = Conexion
.CursorType = CursorTypeEnum.adOpenKeyset
.LockType = LockTypeEnum.adLockOptimistic
.Open("Select*from Form4")
End With
End Sub
Public Sub AbrirDiccionario()
diccionario = New ADODB.Recordset
With diccionario
.ActiveConnection = Conexion
.CursorType = CursorTypeEnum.adOpenKeyset
.LockType = LockTypeEnum.adLockOptimistic
.Open("Select*from Form5")
End With
End Sub
Public Sub AbrirTipo()
tipo = New ADODB.Recordset
With tipo
.ActiveConnection = Conexion
.CursorType = CursorTypeEnum.adOpenKeyset
.LockType = LockTypeEnum.adLockOptimistic
.Open("Select*from Form6")
End With
End Sub
Public Sub CerrarBase()
Try
Conexion.Close()
Catch ex As Exception
MsgBox("ERROR: No se logro el Cierre de Conexi�n a la Base de Datos, ya que la Base
de Datos NO Esta Abierta o NO se Hall�", MsgBoxStyle.Critical,"Error de Cierre de
Conexi�n")
Exit Sub
End Try
Try
Respuesta = Conexion.Errors.Count()
Catch ex As Exception
End Try
If Respuesta = 0 Then
MsgBox("Conexi�n Fue Cerrada Satisfactoriamente",MsgBoxStyle.Information, "Conexi�n
Cerrada")
End If
End Sub
End Module

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem3.Click
If MsgBox("�Desea Salir de la Aplicaci�n", MsgBoxStyle.Question.YesNo,
"CARACTERISTICAS") = MsgBoxResult.Yes Then
Me.Close()
End If
End Sub

Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem1.Click
Dim Editorial As New Form2
Editorial.Show()
Me.Hide()
End Sub

Private Sub CONECTAR_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CONECTAR.Click
Me.Enabled = False
Call AbrirBase()
Me.Enabled = True
GRABAR.Enabled = True
End Sub

Private Sub CERRAR_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CERRAR.Click
Me.Enabled = False
Call CerrarBase()
Me.Enabled = True
End Sub

Private Sub GRABAR_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles GRABAR.Click
If Conexion.State = 1 Then
Call AbrirCaracteristicas()
If caracteristicas.State = 1 Then
caracteristicas.AddNew()
Camposcarac = caracteristicas.Fields
Camposcarac.Item(0).Value = txtpal.Text
Camposcarac.Item(1).Value = txttra.Text
Camposcarac.Item(2).Value = txtsig.Text
caracteristicas.Update()
Else
MsgBox("ERROR: No Se Logr� Abrir La Tabla Amigos",MsgBoxStyle.Critical, "Error al
Guardar")
Exit Sub
End If
Else
MsgBox("ERROR: No Hay Conexi�n Con La Base de Datos",MsgBoxStyle.Critical, "Error
al Guardar")
End If
End Sub

You might also like