1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Private Sub btajout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btajout.Click
Dim strConnexion As String = "Data Source=PC-DE-USER\SQLEXPRESS;Initial Catalog=BDecheance;Integrated Security=True"
Dim strCommand As SqlCommand
Dim strRequete As String = "INSERT INTO reglement(code,numpiece,date,montant,mode,datecheance,numcheque,nombanque,ncin) VALUES(@code,@numpiece,@date,@montant,@mode,@datecheance,@numcheque,@nombanque,@ncin)"
Dim oConnection As New SqlConnection(strConnexion)
strCommand = New SqlCommand(strRequete, oConnection)
With strCommand.Parameters
.Add(New SqlParameter("@code", SqlDbType.Int))
.Add(New SqlParameter("@numpiece", SqlDbType.VarChar, 50))
.Add(New SqlParameter("@date", SqlDbType.DateTime))
.Add(New SqlParameter("@montant", SqlDbType.Int))
.Add(New SqlParameter("@mode", SqlDbType.VarChar, 50))
.Add(New SqlParameter("@datecheance", SqlDbType.DateTime))
.Add(New SqlParameter("@numcheque", SqlDbType.Int))
.Add(New SqlParameter("@nombanque", SqlDbType.VarChar, 50))
.Add(New SqlParameter("@ncin", SqlDbType.Int))
End With
strCommand.Parameters("@code").Value = CInt(tbcode.Text)
strCommand.Parameters("@numpiece").Value = tbnumpiece.Text
strCommand.Parameters("@date").Value = DateTimePicker1.Value.ToShortDateString
strCommand.Parameters("@montant").Value = CInt(tbmontant.Text)
strCommand.Parameters("@mode").Value = cmbmode.Text
strCommand.Parameters("@datecheance").Value = Datecheance.Value.ToShortDateString
strCommand.Parameters("@numcheque").Value = CInt(tbcheq.Text)
strCommand.Parameters("@nombanque").Value = tbbanq.Text
strCommand.Parameters("@ncin").Value = CInt(tbncin.Text)
End Sub |
Partager