Torna al Thread

Private Sub btmInserisci_Click() Dim Agherbino As Database, qdf As QueryDef, strSQL As String Dim numberecord As Integer Dim numberprofile As Integer If IsNull(Me.cmbData.Value) And IsNull(Me.cmbQuadrimestre.Value) And IsNull(Me.cmbTipo.Value) And IsNull(Me.cmbVoto.Value) Then MsgBox "Compilare tutti i campi", vbCritical, "Informazioni mancanti!" Else Dim rec As Recordset Set Agherbino = DBEngine(0)(0) strSQL = "SELECT * FROM Valutazione_prova WHERE Data_prova = '" & Me.cmbData.Value & "' AND Quadrimestre = '" & Me.cmbQuadrimestre.Value & "' AND Tipo = '" & Me.cmbTipo.Value & "' AND Voto = '" & Me.cmbVoto.Value & "'" Set qdf = Agherbino.CreateQueryDef("", strSQL) Set rec = qdf.OpenRecordset(strSQL) numberecord = rec.RecordCount Set rec = Nothing Set qdf = Nothing If numberecord = 0 Then 'effettua un controllo sulla presenza dei campi obbligatori prima di effettuare la query di inserimento strSQL = "INSERT INTO Valutazione_prova(Data_prova, Quadrimestre, Tipo, Voto) VALUES ('" & Me.cmbData.Value & "', '" & Me.cmbQuadrimestre.Value & "', '" & Me.cmbTipo.Value & "', '" & Me.cmbVoto.Value & "')" Agherbino.Execute strSQL strSQL = "SELECT * FROM Valutazione_prova WHERE Data_prova = '" & Me.cmbData.Value & "' AND Quadrimestre = '" & Me.cmbQuadrimestre.Value & "' AND Tipo = '" & Me.cmbTipo.Value & "' AND Voto = '" & Me.cmbVoto.Value & "'" MsgBox "Voto aggiunto correttamente!" Else MsgBox "Attenzione Campi Obbligatori non Valorizzati o non Formalmente Corretti" End If 'se la query iniziale ha restituito per l'utente cercato un risultato allora il messaggio sarà MsgBox "Dipendente già inserito. Modificare i dati del Dipendente" End If 'aggiorna la lista utenti della maschera di gestione 'Form_HomeDocente.ElnVoti.Requery Agherbino.Close 'End If End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5