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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
Public Function getadaptater() As OleDb.OleDbDataAdapter
getadaptater = New OleDb.OleDbDataAdapter
getadaptater.InsertCommand = GetCommandInsert()
getadaptater.UpdateCommand = GetCommandUpdate()
getadaptater.DeleteCommand = GetCommandDelete()
End Function
Public Overrides Function getCommandInsert() As OleDb.OleDbCommand
Dim strSql As String
strSql = "Insert into " & strBibliothequeEtFichier & "(" _
& " AFCNI , AFCDOS , AFCDO2 , AFCDO3 , AFCNOM , " _
& ") values(" _
& " ?, ?, ?, ?, ?)"
Dim cmd As OleDb.OleDbCommand = connection.CreateCommand
cmd.CommandText = strSql
cmd.Parameters.Add("iAFCNI", OleDb.OleDbType.Integer, 7, "AFCNI")
cmd.Parameters.Add("iAFCDOS", OleDb.OleDbType.VarChar, 3, "AFCDOS")
cmd.Parameters.Add("iAFCDO2", OleDb.OleDbType.VarChar, 15, "AFCDO2")
cmd.Parameters.Add("iAFCDO3", OleDb.OleDbType.Integer, 2, "AFCDO3")
cmd.Parameters.Add("iAFCNOM", OleDb.OleDbType.VarChar, 40, "AFCNOM")
Return cmd
End Function
Public Overrides Function getCommandUpdate() As OleDb.OleDbCommand
Dim strSql As String
strSql = "Update " & strBibliothequeEtFichier & " set" _
& " AFCNI = ?, AFCDOS = ?, AFCDO2 = ?, AFCDO3 = ?, AFCNOM = ?, " _
& " where " _
& " AFCNI = ? and AFCDOS = ? and AFCDO2 = ? and AFCDO3 = ? and AFCNOM = ? "
Dim cmd As OleDb.OleDbCommand = connection.CreateCommand
cmd.CommandText = strSql
cmd.Parameters.Add("iAFCNI", OleDb.OleDbType.Integer, 7, "AFCNI").SourceVersion = DataRowVersion.Current
cmd.Parameters.Add("iAFCDOS", OleDb.OleDbType.VarChar, 3, "AFCDOS").SourceVersion = DataRowVersion.Current
cmd.Parameters.Add("iAFCDO2", OleDb.OleDbType.VarChar, 15, "AFCDO2").SourceVersion = DataRowVersion.Current
cmd.Parameters.Add("iAFCDO3", OleDb.OleDbType.Integer, 2, "AFCDO3").SourceVersion = DataRowVersion.Current
cmd.Parameters.Add("iAFCNOM", OleDb.OleDbType.VarChar, 40, "AFCNOM").SourceVersion = DataRowVersion.Current
'Where
cmd.Parameters.Add("oAFCNI", OleDb.OleDbType.Integer, 7, "AFCNI").SourceVersion = DataRowVersion.Original
cmd.Parameters.Add("oAFCDOS", OleDb.OleDbType.VarChar, 3, "AFCDOS").SourceVersion = DataRowVersion.Original
cmd.Parameters.Add("oAFCDO2", OleDb.OleDbType.VarChar, 15, "AFCDO2").SourceVersion = DataRowVersion.Original
cmd.Parameters.Add("oAFCDO3", OleDb.OleDbType.Integer, 2, "AFCDO3").SourceVersion = DataRowVersion.Original
cmd.Parameters.Add("oAFCNOM", OleDb.OleDbType.VarChar, 40, "AFCNOM").SourceVersion = DataRowVersion.Original
Return cmd
End Function
Public Overrides Function getCommandDelete() As OleDb.OleDbCommand
Dim strSql As String
strSql = "Delete from " & strBibliothequeEtFichier & " where" _
& " AFCNI = ? and AFCDOS = ? and AFCDO2 = ? and AFCDO3 = ? and AFCNOM = ? "
Dim cmd As OleDb.OleDbCommand = connection.CreateCommand
cmd.CommandText = strSql
cmd.Parameters.Add("oAFCNI", OleDb.OleDbType.Integer, 7, "AFCNI").SourceVersion = DataRowVersion.Original
cmd.Parameters.Add("oAFCDOS", OleDb.OleDbType.VarChar, 3, "AFCDOS").SourceVersion = DataRowVersion.Original
cmd.Parameters.Add("oAFCDO2", OleDb.OleDbType.VarChar, 15, "AFCDO2").SourceVersion = DataRowVersion.Original
cmd.Parameters.Add("oAFCDO3", OleDb.OleDbType.Integer, 2, "AFCDO3").SourceVersion = DataRowVersion.Original
cmd.Parameters.Add("oAFCNOM", OleDb.OleDbType.VarChar, 40, "AFCNOM").SourceVersion = DataRowVersion.Original
Return cmd
End Function
Public Sub update()
Dim adaptater As OleDb.OleDbDataAdapter
adaptater = getadaptater()
adaptater.Update(table)
End Sub |
Partager