You are on page 1of 2

Option Explicit On Imports System.Data.OleDb Module Module1 Dim bd As OleDb.

OleDbConnection 'variable global Db Puede tomar cualquie let ra Structure libro Dim codigo As Integer Dim titulo As String Dim autor As String Dim editorial As String Dim edicion As Integer Dim precio As Double Dim nrocopias As Integer Dim tema As String End Structure Sub Main() Dim opc1 As Integer Call conectar() Do While opc1 <> 5 Call menu1(opc1) Select Case opc1 Case 1 : Call newlib() Case 2 : Call consul() Case 3 : Call modpre() Case 4 End Select Loop If opc1 = 5 Then MsgBox("fue un placer servirle su cuenta es ") End If End Sub Sub menu1(ByRef op As Integer) Dim A As String A = "**--LIBRERIA--**" & Chr(10) & Chr(10) A = A & "1. INGRESAR LIBRO" & Chr(10) A = A & "2. COSULTAR LIBRO" & Chr(10) A = A & "3. MODIFICAR PRECIO DEL LIBRO" & Chr(10) A = A & "4. ELIMINAR" & Chr(10) A = A & "5. SALIR" & Chr(10) & Chr(10) A = A & "SELECCIONE SU OPCION" op = InputBox(A, "Libreria") End Sub Sub newlib() Dim rs As OleDb.OleDbCommand 'referencia registro Dim est As libro Dim sent_SQL As String

est.titulo = InputBox("ingresar el nombre del libro") est.codigo = InputBox("ingresar el codigo de libro") est.autor = InputBox("ingresar el autor") est.editorial = InputBox("ingresar la editorial del libro") est.edicion = InputBox("ingresar la edicion del libro") est.precio = InputBox("ingresar el precio del libro") bd.Open() 'nombre de la tabla sent_SQL = "insert into Tabla1 (titulo, autor, editorial, edicion, preci o) values ('" & est.titulo & "', '" & est.autor & "', '" & est.editorial & "', " & est.edicion & ", " & est.precio & ")" rs = New OleDb.OleDbCommand(sent_SQL, bd) rs.ExecuteNonQuery() bd.Close() MsgBox("datos grabados")

End Sub Sub consul() MsgBox("consultar libro") End Sub Sub modpre() MsgBox("modificar precio") End Sub Sub conectar() Dim senten As String 'sentencia o instruccion senten = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Users\salaest udio\Documents\sppc\libreria.mdb " bd = New OleDb.OleDbConnection(senten) MsgBox("conexion con base de datos estable") End Sub End Module

You might also like