Bonjour,
Depuis que j'ai mis à jour ma version de XP en SP3, je n'arrive plus à créer de nouvel enregistrement dans ma base access. Mes instructions n'ont pourtant pas été modifiées. Que j'opte pour VB Net ou VB 2005, aucune création. Je ne rencontre pourtant aucune erreur lors du déroulement de la routine.
Code vb : Sélectionner tout - Visualiser dans une fenêtre à part
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 ' Private Sub AJOUT() ' Dim RqtSql As String = Prm_Zne.Dta.Substring(Pgm_Zne.Lng, (Prm_Zne.Dta.Length - Pgm_Zne.Lng)) RqtSql = RqtSql.Replace("COUNT(*) AS NBR_ENRG", "*") Dim DtaRow As DataRow Dim DtaSet As New DataSet Dim DtaAdapt As New OleDbDataAdapter(RqtSql, DbCnx) DtaSet.Clear() Try DbCnx.Open() Try DtaAdapt.Fill(DtaSet, "tbl" & Pgm_Zne.Tbl) Try 'DtaSet.Tables("tbl" & Pgm_Zne.Tbl).Rows.Add() DtaRow = DtaSet.Tables("tbl" & Pgm_Zne.Tbl).NewRow Try DtaRow(Pgm_Zne.Tbl & "_Cod") = lblCode.Text DtaRow(Pgm_Zne.Tbl & "_Lib_Lg") = txtLib_Lg.Text Select Case Pgm_Zne.Tbl Case "Pys" DtaRow(Pgm_Zne.Tbl & "_Lib_Ct") = txtLib_Ct.Text End Select Try Dim CmdBuild As New OleDbCommandBuilder(DtaAdapt) DtaAdapt.UpdateCommand = CmdBuild.GetUpdateCommand DtaAdapt.Update(DtaSet, "tbl" & Pgm_Zne.Tbl) Err_Msg = "Un enregistrement a été créé" & _ vbCrLf & "dans la table tbl" & Pgm_Zne.Tbl Catch ex As Exception ' Mise à jour de la table non réalisée Err_Msg = ex.Message End Try Catch ex As Exception ' Alimentation des champs de la table non réalisée Err_Msg = ex.Message End Try Catch ex As Exception ' Ligne d'insertion non construite Err_Msg = ex.Message End Try Catch ex As Exception ' Transfert d'informations impossible (remplissage DataAdapter) Err_Msg = ex.Message End Try Catch ex As Exception ' Accès Base de Données impossible Err_Msg = ex.Message End Try DbCnx.Close() ' End Sub
J'ai tenté de remplacer GetUpdateCommand par GetInsertCommand, sans effet.
Avez-vous déjà rencontré ce pbm ? Puis-je avoir une piste por me dépanner ?
Partager