0 Replies Latest reply on Sep 3, 2008 7:03 AM by EvolvedDSM

    FDS only creating one item per session

    EvolvedDSM Level 2
      I'm using a ColdFusion data source assigned to a MS-SQL database. The database has a primary key with data type set to smallint, auto-increment/identity = yes.

      I'm using the CFC wizard to create my CFCs and actionscript valueObject. My application is basic so far, just a data grid and a 3-field form. When I run my app, the data grid populates properly with the data from my MS-SQL db. I can fill out the form and submit the data, which adds another record to my database and is immediately reflected in the data grid. However, if I try to add additional records, the application does not do anything. I have to refresh my app each time I want to add a new record.

      I'm using DataService to handle my data (along with FDS which is running on my server).

      here's my basic setup

      import mx.data.DataService;
      import mx.collections.ArrayCollection;
      import valueObjects.myTable; // created by CFC Wizard

      private var ds:DataService;
      private var ac:ArrayCollection;
      private var myObject:myTable;

      private function initApp():void{ // this is called from creationComplete
      ds = new DataService("myds");
      ac = new ArrayCollection();

      private function newRecord():void{
      myObject = new myTable;
      myObject.col1 = field1.text;
      myObject.col2 = field2.text;
      myObject.col3 = field3.text;
      resetForm() // just a method that clears the form fields for additional entries

      So I fill the fields out (field1, 2, 3) and hit the submit button, which calls newRecord(). This will insert my newly created record into my database and will also immediately display in the datagrid. But from this point on, no new records can be added without manually refreshing the browser.

      My work-around for this is adding ds.release(); and ds.fill(ac); after ds.createItem(myObject); While this works, it's very clunky. Each record I add clears the datagrid and repopulates it, creating a "flash" of the datagrid in which things disappear and then reappear. It's only a minor cosmetic flaw, but to myself it's an eye sore. I've created MS access db apps using the same code and I've never had to release and refill my ds.

      So what could be going on that would prevent new items from being added? I am 100% sure that my app fails when calling ds.createItem() twice or more times.