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 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Public Sub inserer_projet(ByVal table As String, _
ByVal proj_nom As String, ByVal proj_resp As String, _
ByVal proj_dat As Date, ByVal proj_particip As String, _
ByVal proj_num As String, ByVal proj_desc As String)
Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Documents and Settings\...\maBase.mdb"
Dim maConnexion As New OleDb.OleDbConnection(connectString)
Try
Dim laDate As Date
laDate = proj_dat.ToShortDateString()
Dim myCommand As New OleDb.OleDbCommand
'ouverture de connexion BD
maConnexion.Open()
myCommand.Connection = maConnexion
'initialisation de la requète
myCommand.CommandText = "INSERT INTO " & table & _
"(projet_id, projet_libelle, projet_responsable, projet_date_crea,
projet_particip, projet_num, projet_descriptif) VALUES (projet_id.nextval,
" + "'" + proj_nom + "'" + ", " + "'" + proj_resp + "'" + ", " _
+ laDate + ", " + "'" + proj_particip + "'" + ", " _
+ "'" + proj_num + "'" + ", " + "'" + proj_desc + "'" + ")"
myCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message.ToString, "Erreur",
MessageBoxButtons.OK, MessageBoxIcon.Stop)
Finally
'fermeture connexion BD
maConnexion.Close()
End Try
End Sub |
Partager