• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Flex form to insert data into Database

Guest
Sep 07, 2010 Sep 07, 2010

Copy link to clipboard

Copied

Hey!

I'm new to Flex and am trying to get a few basic features working.

I've followed a couple video tutorials on how to create a form and have it insert the data to your database, but for some reason the data never gets written to the DB.

I've followed the following 2 tutorials:

http://www.youtube.com/watch?v=MGCrRlC4i5E

http://www.adobe.com/devnet/flex/testdrive/articles/2_modify_the_database.html

Both were quite easy to follow but for some reason when I run the application and enter data nothing gets saved to the database...  Anyone else have this issue or any information that may help in resolving this issue?

Thanks!

Views

3.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

Funny you should say that. I logged onto these forums because I had been following the

"Build an application in an hour" tutorial (Employees/Departments) and ran into exactly the same hurdle. Everything seems to work fine (I can retrieve my records) but when I go to Add a record and hit Submit NOTHING happens. No error messages, no record in the database, nothing. Now the difference is that I'm trying to use an SQL Server 2008 Express database through ColdFusion. My DSN in the CF Administrator validates fine and Flash remoting is set to on but nothing happens.

I saw a poster with a similar issue in the comments section of one of those tutorials but the response from an Adobe tech was, to put it mildly, inscrutable.

I'm actually comparing/contrasting C# (WebForms/MVC) and FlashBuilder for a web project I'm undertaking and while the Flash interface and coding model seems a bit cleaner/easier the data actually DOES get written in C#.

Good Luck, I'll root around a bit more to see what I come up with on this issue.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

Are you creating the Employee object every time when you want to create a new employee, because if its not done, it might have the value ID as the previous one and it might fail adding the new record to the database (if the id is an auto id)

Thanks

-Sunil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

Tried that and still nothing...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

Thanks for the reply.  Fingers crossed because this is quite frustrating...

Another thing that should be mentioned is when I update a record through a flex application it updates the data in the flex datagrid but the changes don't get updated in the DB....

Thanks again,

Don

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

So I assume you can RETRIEVE the records?

What kind of data service? PHP? CF?

I am not using the test employee database, I've got a separate table with an Identity int primary key (not nullable, of course), other fields are strings which DO allow nulls, plus a byte array.

As suggested, when the "Add" button is click I create a new object; e.g. address = new Address(). I DON'T input the key column. What I notice is that when I click Submit NOTHING happens. It doesn't look like the app is actually calling the service (there is NO error message and apparently NO disk activity). So I don't even think it's TRYING to get to the database.

We shall see.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

I can retrieve the records and plot data in some graphs and data grids.

I have a WAMP set up so I'm using MySQL and PHP as my DB and service.

Sounds like our issue is similar...  I've even tried putting in a new state so when you click on the add record button it sends you to a new page/state. That works fine, but again the data doesn't get saved.

Here's the code for my add event...

protected function button3_clickHandler(event:MouseEvent):void

{

var employee5:Employee = new Employee();

employee5.id = parseInt(idTextInput2.text);

employee5.first = firstTextInput3.text;

employee5.last = lastTextInput3.text;

createEmployeeResult3.token = employeeService.createEmployee(employee5);

currentState="Done";

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

If your id is auto id, take off the assignment for employee5.id, I think that is the reason why it will fail.

Thanks

-Sunil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

There are 2 reasons why this could be happening.

a. If you have enabled datamanagement for your service, you have to manually do a commit, as it is set to off by default.

b. there is an issue with the service call, either its not happening or the server side function has syntactical or SQL errors.

Can you enable Network monitor to check whether the request that the application is sending and the response it is getting back are in line with your expectations.

Thanks

-Sunil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

I'm assuming that the function is correct since it was generated by Flash Builder 4...   And having some experience with PHP the syntax looks ok.

I have a feeling it could be something with the enabled "datamanagement" and the commit...?

Do you have instructions or resources on how to either disable datamanagement for the service or how to do the manual commit?

Thanks,

Don

P.S.  I took out the ID assignment and still nothing...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

This should help you to understand the autocommit option http://help.adobe.com/en_US/Flex/4.0/AccessingData/WSbde04e3d3e6474c4-56c6d6d11210238e6e8-8000.html#WSbde04e3d3e6474c4-2ced3c791210307ae27-8000

Thanks

-Sunil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

This sounds like it's the issue.

Since I'm still learning this and I'm a little un-familiar with the syntax...

Where abouts would this go and what needs to be changes in the syntax...

For example if this is my create event statement:

protected function button3_clickHandler(event:MouseEvent):void

{

var employee5:Employee = new Employee();

//employee5.id = parseInt(idTextInput2.text);

employee5.first = firstTextInput3.text;

employee5.last = lastTextInput3.text;

createEmployeeResult3.token = employeeService.createEmployee(employee5);

currentState="Done";

}

I would now assume that "bookService.getDataManager(bookService.DATA_MANAGER__BOOK).autoCommit = true;" needs to go somewhere in that event and also the syntax needs to be updated...?

Thanks again for all your help with this!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

Great, You can set autocommit to true once for the service, not everytime.

Can you please file a bug for us to

a. auto generate the autocommit to be set to true

b. generate some comments explaining what autocommit does.

Thanks

-Sunil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

Based on this create new Employee event can you show me how the syntax would look to set this to autocommit?

protected function button3_clickHandler(event:MouseEvent):void

{

var employee5:Employee = new Employee();

//employee5.id = parseInt(idTextInput2.text);

employee5.first = firstTextInput3.text;

employee5.last = lastTextInput3.text;

createEmployeeResult3.token = employeeService.createEmployee(employee5);

currentState="Done";

}

Where does this line of code go, "bookService.getDataManager(bookService.DATA_MANAGER__BOOK).autoCommit = true;", and how does the syntax change based on the above snippet?

Thanks and I'll submit an issue for this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

The autocommit setting can go in the application's creationcomplete event or you could create a button to toggle this setting in your user interface.

Thanks

-Sunil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

Fixed!!

For those of you who have had this issue...  Here's my code for creating a new employee with the commit()

protected function button3_clickHandler(event:MouseEvent):void

{

var employee5:Employee = new Employee();

//employee5.id = parseInt(idTextInput2.text);

employee5.first = firstTextInput3.text;

employee5.last = lastTextInput3.text;

createEmployeeResult3.token = employeeService.createEmployee(employee5);

employeeService.commit();

currentState="Done";

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 13, 2010 Sep 13, 2010

Copy link to clipboard

Copied

LATEST

WOW, THANKS

Somebody really blew it in training.

That little omission of an absurdly obvious requirement just caused me three days of pure hell.

EVERYONE uses auto increment on a table if they know what they are doing and it should be  understood that a lot of people need to know about

commitIO

Jesus

P.S. is there anyway we can all give dondoiron a star for the answer.

He deserves a dozen.

Dan Pride

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

I think Sunil mentioned the same thing as in the comments to the "Flex in an Hour" tutorial: commit(). I was going to ask if this was explained anywhere as it's not mentioned anywhere in the tutorial. However, I see Sunil's last post and I will take a look. If your click of "Submit" is not doing ANYTHING then that might be the issue (as if it was an error you'd see an error message, there's a fault handler in the code).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines