Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Table not updated.
Message
De
14/06/2007 04:11:12
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Table not updated.
Divers
Thread ID:
01232865
Message ID:
01232865
Vues:
47
I create a row, I add the row, I accept changes. Row never gets added to the SQL table. Am I missing a step? Doing something wrong?

Note sure how to debug this further.
cdsDataDataSet.XRefRow dr = xref.NewXRefRow();
dr.display = "Hi There";
xref.Rows.Add(dr);
xref.AcceptChanges();
The code is very ugly, and var names are garbage cause I'm just playing around trying to see how things work. But hopefully I have what you need to see here:
// ********** jobTree.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace cdsJobs
  {
  public partial class jobTree : WeifenLuo.WinFormsUI.Docking.DockContent
    {
    cdsDataDataSet dsXRef;
    cdsDataDataSet.XRefDataTable xref;
    cdsDataDataSetTableAdapters.XRefTableAdapter dsTA;

    public jobTree()
      {
      InitializeComponent();

      dsXRef = new cdsDataDataSet();
      dsTA   = new cdsDataDataSetTableAdapters.XRefTableAdapter();
      xref   = dsTA.GetData();

      cdsNode tn = new cdsNode();
      tn.Text = xref[0].display;
      tn.rec = 0;
      treeView.Nodes.Add(tn);
      }

    private void OnTreeContextMenuSelect(object sender, EventArgs e)
      {
      cdsDataDataSet.XRefRow dr = xref.NewXRefRow();
      dr.display = "Hi There";
      xref.Rows.Add(dr);
      Int32 id = xref[0].id;
      cdsNode tn = new cdsNode();
      tn.Text = "Test" + id.ToString("00000000");
      tn.rec = xref.Rows.Count - 1;
      treeView.SelectedNode.Nodes.Add(tn);
      treeView.SelectedNode = tn;
      xref.AcceptChanges();
      }
  }

  public class cdsNode : TreeNode 
      {
      public int rec = 0;
      }
}


// ********** Auto generated from dataset.cs

this._adapter.InsertCommand = new System.Data.SqlClient.SqlCommand();
this._adapter.InsertCommand.Connection = this.Connection;
this._adapter.InsertCommand.CommandText = "INSERT INTO [XRef] ([root], [parent], [DisplayOrder], [xref], [type], [alias], [d" +
                "isplay], [value], [freq], [lastused]) VALUES (@root, @parent, @DisplayOrder, @xr" +
                "ef, @type, @alias, @display, @value, @freq, @lastused)";
            this._adapter.InsertCommand.CommandType = System.Data.CommandType.Text;
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform