Hello!

Code : 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
        Try
            BDDDataSet = New DataSet()
            BDDConnection = New OleDbConnection()
            BDDConnection.ConnectionString = ParametreConnection
            Try
                BDDConnection.Open()
            Catch
                MsgBox("Vous devez ouvrir une Base de donnée Access avant toute opération.")
            End Try
            BDDCommand = New OleDbCommand("SELECT USER, MDP FROM Users")
            BDDDataAdapter = New OleDbDataAdapter(BDDCommand)
            BDDCommand.Connection() = BDDConnection
            BDDDataAdapter.Fill(BDDDataSet, "Users")
            BDDConnection.Close()
 
        Catch ex As Exception
            MsgBox("Erreur connection BDD: " & ex.Message)
        End Try
 
        BDDDataRow = BDDDataSet.Tables("Users").NewRow()
        BDDDataRow("USER") = System.Environment.UserName
        BDDDataRow("MDP") = TextBox1.Text
        BDDDataSet.Tables("Users").Rows.Add(BDDDataRow)
 
        BDDDataAdapter.Update(BDDDataSet, "Users")
        BDDConnection.Close()
Lorsque je rempli la textbox et que j'appuie qur le bouton qui declenche cette fonction, VS 2008 me retourne l'erreur suivante:


L'exception System.InvalidOperationException n'a pas été gérée
Message="Update requiert un InsertCommand valide lors du passage de la collection DataRow avec de nouvelles lignes."
Source="System.Data"
StackTrace:
à System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) à System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) à System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) à System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping) à System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) à Apli_Vigneron.Form2.Button1_Click(Object sender, EventArgs e) dans C:\Users\Adrien\Documents\Visual Studio 2008\Projects\Apli_Vigneron\My Project\Form2.vb:ligne 36 à System.Windows.Forms.Control.OnClick(EventArgs e) à System.Windows.Forms.Button.OnClick(EventArgs e) à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) à System.Windows.Forms.Control.WndProc(Message& m) à System.Windows.Forms.ButtonBase.WndProc(Message& m) à System.Windows.Forms.Button.WndProc(Message& m) à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) à System.Windows.Forms.Application.Run(ApplicationContext context) à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) à Apli_Vigneron.My.MyApplication.Main(String[] Args) dans 17d14f5c-a337-4978-8281-53493378c1071.vb:ligne 81 à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) à System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) à System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel) à System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() à System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData) à System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext) à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() à System.Threading.ThreadHelper.ThreadStart_Context(Object state) à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) à System.Threading.ThreadHelper.ThreadStart()
InnerException:

C'est la première fois que je vois ce type d'erreur et j'ai demandé à plusieurs amis programmeurs, ils ne connaissent pas non plus.

Merki!