Torna al Thread

Imports System.Data Imports System.Data.OleDb Public Class frmCARRELLO Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\DbOggetti.mdb") Dim cmd As OleDbCommand Dim daCARRELLO As OleDbDataAdapter Dim dtCARRELLO As DataTable Private Sub btnINSERT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnINSERT.Click insertCARRELLO() End Sub Public Sub insertCARRELLO() If Me.cmbDESCRIZIONE.Text = "" Then MsgBox("Selezionare un componente da aggiungere dall'elenco") Me.cmbDESCRIZIONE.Focus() Exit Sub End If Try conn.Open() cmd = New OleDbCommand("INSERT INTO Carrello (Descrizione, Quantita, Elimina) VALUES (@Descrizione , @Quantita ,'0')", conn) cmd.Parameters.Add("@Descrizione", OleDbType.Char).Value = Me.cmbDESCRIZIONE.Text cmd.Parameters.Add("@Quantita", OleDbType.Integer).Value = Me.nudQUANTITA.Value MsgBox(cmd.Parameters.Item(0).Value) 'Qui posso verificare il parametro MsgBox(cmd.Parameters.Item(1).Value) 'Qui posso verificare il parametro MsgBox(cmd.CommandText.ToString) 'Qui posso verificare la query cmd.ExecuteNonQuery() conn.Close() 'Ricarico il DB nel DataGrid loadCARRELLO() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Public Sub loadCARRELLO() Try conn.Open() cmd = New OleDbCommand("SELECT * FROM Carrello", conn) daCARRELLO = New OleDbDataAdapter() daCARRELLO.SelectCommand = cmd dtCARRELLO = New DataTable() daCARRELLO.Fill(dtCARRELLO) Me.dgvCARRELLO.DataSource = Me.dtCARRELLO conn.Close() Catch ex As Exception MsgBox(ex.Message) End Try 'Ecc ecc End Class
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5