un Oledbcommandbuilder qui bloque
Bonjour :D
je suis en projet pour la mise en place d'un fornulaire de banque mais j'ai des lacunes :
j'utilise une petite BD access je suis arrive à faire une recherche dans la BD et de faire des nouveaux enregistrement dans la table de la BD mais mon probleme figure dans la modification d'un enregistrement existant ce qui fait bloquer l'application voici quelques details de l'erreur que j'ai eu :
le stacktrace de l'erreur:
Citation:
System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217900
Message="Erreur de syntaxe (opérateur absent) dans l'expression '(((? = 1 AND TypeDeMessage IS NULL) OR (TypeDeMessage = ?)) AND ((? = 1 AND Destinataire IS NULL) OR (Destinataire = ?)) AND (M20 = ?) AND ((? = 1 AND M23ADate IS NULL) OR (M23ADate = ?)) AND ((? = 1 AND M23ADevise IS NULL) OR (M23ADevise = ?)) AND ((? = '."
Source="Microsoft JET Database Engine"
StackTrace:
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at Swift2.Module1.enregister(Enregistrement& swifts, Sw& forme) in C:\Documents and Settings\Mohamed\Bureau\Visual Basic\Projets\VB8\Swift2\Swift2\Module1.vb:line 336
at Swift2.MDIParent1.SaveToolStripButton_Click(Object sender, EventArgs e) in C:\Documents and Settings\Mohamed\Bureau\Visual Basic\Projets\VB8\Swift2\Swift2\MDIParent1.vb:line 114
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Swift2.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
sachant que pour faire cette commande(modifications d'enregistrement existant) j'utilise les memes objets que pour cree un nouveau enregistrement - je fais les 2 operations dans la meme fonction - il y a juste un IF ELSE qui fait la difference et pourtant ça ne plante que pour la modification :
voici une partie du code :
Code:
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
|
Dim Nblignes As Integer
Dim Connexion As OleDbConnection
Dim Commande As OleDbCommand
Dim Adapter As OleDbDataAdapter
Dim Conteneur As New DataSet()
Dim Table As DataTable
Dim ligne As DataRow
Dim compilateur As OleDbCommandBuilder
Connexion = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + DBname)
Commande = New OleDbCommand("Select * from Swift")
Connexion.Open()
Adapter = New OleDbDataAdapter(Commande)
Commande.Connection() = Connexion
Adapter.Fill(Conteneur, "Swift")
Table = Conteneur.Tables("Swift")
M20 = forme.TextBox3.Text
If remplirClass(swifts, forme, 1) Then
'dans le cas d'une modification
For Nblignes = 0 To Table.Rows.Count - 1
If Table.Rows(Nblignes).Item("M20") = M20 Then
ligne = Conteneur.Tables("Swift").Rows(Nblignes)
ligne("TypeDeMessage") = swifts.Type_de_message
ligne("Destinataire") = forme.TextBox2.Text
ligne("M23ADate") = swifts.M23A_date
ligne("M23ADevise") = swifts.M23A_devise
ligne("M23Montant") = swifts.M23A_montant
ligne("M50K") = swifts.M50K
ligne("BanqueInter") = swifts.Banque_inter
ligne("O57A") = swifts.O57A
ligne("O57D") = swifts.O57D
ligne("M59") = swifts.M59
ligne("O70") = swifts.O70
ligne("71A") = swifts._71A
Exit For
End If
Next
Else
' dans le cas d'un nouveau enregistrement
ligne = Conteneur.Tables("Swift").NewRow()
ligne("TypeDeMessage") = swifts.Type_de_message
ligne("Destinataire") = swifts.Destinataires
ligne("M20") = swifts.M20
ligne("M23ADate") = swifts.M23A_date
ligne("M23ADevise") = swifts.M23A_devise
ligne("M23Montant") = swifts.M23A_montant
ligne("M50K") = swifts.M50K
ligne("BanqueInter") = swifts.Banque_inter
ligne("O57A") = swifts.O57A
ligne("O57D") = swifts.O57D
ligne("M59") = swifts.M59
ligne("O70") = swifts.O70
ligne("71A") = swifts._71A
Conteneur.Tables("Swift").Rows.Add(ligne)
End If
compilateur = New OleDbCommandBuilder(Adapter)
' l'erreur ce declenche à ce niveau
Adapter.Update(Conteneur, "Swift")
Connexion.Close()
Commande = Nothing
Adapter = Nothing
Conteneur = Nothing
Table = Nothing
ligne = Nothing |
http://www.image-serveur.com/uploads/02a1e70c4f.jpg
Citation:
je travaille sur VISUAL STUDIO 2005 Pro
merci pour votre aide