Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Database ADO LIbri - Frmlibri.frm

Frmlibri.frm

Caricato da: Albertking82
Scarica il programma completo

  1. Dim col As Integer, num As Integer
  2. Dim v(1 To 10) As String
  3. Dim r As Integer
  4. Dim conn As Connection
  5. Dim rs As Recordset
  6. Public sql As String
  7.  
  8. Sub init()
  9.  
  10. With Frmlibri.DataGrid1
  11.    
  12.     .AllowAddNew = False
  13.     .AllowDelete = False
  14.     .AllowUpdate = False
  15.    
  16.   End With
  17.  
  18. End Sub
  19. Sub query(str As String)
  20.  
  21.  Set cn = New ADODB.Connection
  22.  Set rs = New ADODB.Recordset
  23.  cn.Provider = "microsoft.jet.oledb.4.0"
  24.  cn.ConnectionString = "c:\libri\libri.mdb"
  25.  cn.Open
  26.  rs.LockType = adLockOptimistic
  27.  rs.CursorLocation = adUseClient
  28.  rs.Source = str
  29.  Set rs.ActiveConnection = cn
  30.  rs.Open
  31.  
  32.  If rs.EOF Then
  33.  
  34.    MsgBox "Nessun record trovato", vbInformation, "Ricerca fallita"
  35.    Exit Sub
  36.    
  37.  End If
  38.  
  39.   Set Frmlibri.DataGrid1.DataSource = rs
  40.  
  41. End Sub
  42.  
  43. Private Sub DataGrid1_AfterInsert()
  44. DataGrid1.BackColor = vbGreen
  45. End Sub
  46.  
  47. Private Sub DataGrid1_OnAddNew()
  48. DataGrid1.BackColor = vbYellow
  49.  
  50. End Sub
  51.  
  52. Private Sub mnuall_Click()
  53.  
  54. sql = "select * from libri;"
  55. Call query(sql)
  56. Call init
  57. End Sub
  58.  
  59. Private Sub mnuaut_Click()
  60. stringa = InputBox("inserisci autore", "Inserisci autore")
  61.  If stringa = "" Then
  62.   MsgBox "Input errato!", vbInformation, "Input errato"
  63.   Exit Sub
  64.  End If
  65. sql = "select * from libri where autore='" & stringa & "';"
  66. Call query(sql)
  67. Call init
  68. End Sub
  69.  
  70. Private Sub mnugen_Click()
  71.  stringa = InputBox("inserisci genere", "Inserisci genere")
  72.  If stringa = "" Then
  73.   MsgBox "Input errato!", vbInformation, "Input errato"
  74.   Exit Sub
  75.  End If
  76. sql = "select * from libri where genere='" & stringa & "';"
  77. Call query(sql)
  78. Call init
  79. End Sub
  80.  
  81. Private Sub mnuop_Click()
  82.  
  83. With Frmlibri.DataGrid1
  84.    
  85.     .AllowAddNew = True
  86.     .AllowDelete = True
  87.     .AllowUpdate = True
  88.    
  89.   End With
  90.  
  91.   sql = "select * from libri;"
  92.   Call query(sql)
  93.  
  94.  
  95. End Sub
  96.  
  97. Private Sub mnutit_Click()
  98.  stringa = InputBox("inserisci titolo libro", "Inserisci titolo libro")
  99.  If stringa = "" Then
  100.   MsgBox "Input errato!", vbInformation, "Input errato"
  101.   Exit Sub
  102.  End If
  103. sql = "select * from libri where titolo='" & stringa & "';"
  104. Call query(sql)
  105. Call init
  106. End Sub
  107.  
  108. Private Sub mnutot_Click()
  109. sql = "select count(idlibro)as Totale_libri from libri;"
  110. Call query(sql)
  111. Call init
  112.  
  113. End Sub