7 Replies Latest reply on Oct 5, 2007 11:01 AM by GregoryWexler

    Populate Datagrid from database

      Using Adobe Flex Builder 3 Beta 2, I have successfully used the Data Source Explorer window to connect to the Northwind and Pubs database on my SQL 2005 server. I can see the schemas and tables, etc. I understand that currently I cannot simply drag and drop the fields into the datagrid (which would be nice) so how do I 'wire up' a table to the data grid? Is there an example which you can refer me to (with source) that would explain that? I've successfully wired up a webservice, but not to a database listed in the Data Source Explorer. If there were an example that showed a CRUD data grid, that would help.
        • 1. Re: Populate Datagrid from database
          catalinanastasoaie Level 1
          Hi Gregory,

          You can generate a simple CRUD application, which then can be used as a starting point, with the Create Application from Database... feature that can be accessed from Flex Builder menu > Data > Create Application from Database... or by right clicking on a database table in the Data Source Explorer panel and choosing Create Application from Database....

          So now that you have created the connection to the Northwind database you just need to create a ASP.NET server type project and use the Create Application from Database option as explained above.

          • 2. Re: Populate Datagrid from database
            GregoryWexler Level 1
            Hi Catalin:

            When I created a new flex project and specified the application server type as ASP.NET, the next screen prompted for selection of one of two radio buttons:
            (x) Use ASP .NET Development Server
            ( ) Use Internet Information Services (IIS).

            As I selected 'Use ASP .NET Development Server', I could not continue on that wizard because stops me with "You don't have ASP .NET Development Server Installed."

            I went ahead and installed 'Microsoft Visual Web Developer 2005 Express Edition' which comes with the 'ASP .NET Development Server' and createed a simple web page. Next I restarted Flex Builder and began the wizard to create an ASP.NET Server Type Flex Project and still I ran into the same issue: 'You don't have ASP .NET Development Server Installed. That's strange because I can see the icon for the ASP .NET Development Server running and the port # that it's running on.

            So I fugured, maybe I need to load Visual Studio 2005 (full release) rather than the Express release. Unfortunately, I STILL get the same error when using the wizard to create a New Flex Project with ASP. NET server: "You don't have ASP .NET Development Server Installed."

            Any thoughts?
            • 3. Re: Populate Datagrid from database
              catalinanastasoaie Level 1
              Can you tell us what version of .NET Framework are you using ? We support the 2.0 version.

              • 4. Re: Populate Datagrid from database
                GregoryWexler Level 1
                I have .NET framework 2.0 installed. I'm assuming that's what's being used by the Flex Builder 3 Beta 2 environment.
                • 5. Re: Populate Datagrid from database
                  GregoryWexler Level 1
                  Just to give you an update as to where I am and where I'm hung up, I was able to make a little bit of progress but not too far.

                  1. I created a Flex Project (Web application) and specify Applcation Server Type: ASP.net.
                  2. Next, I have the choice of specifying 'Use ASP .NET Development Server' or 'Use Internet Information Services (IIS). At the 'Usa ASP .NET Development Server', the error message at the top of this wizard window says (X) You don't have ASP .NET Development Server Installed. [Well, it may not be running but I do have it installed as part of the .NET 2.0 Framework.. it does exist]. So, because of the error, I have no choice but to use the alternate option, 'Use Internet Information Services (IIS).
                  3. I specify my Web Application Root: d:\Flex3 Projects\TestProj3 (I manually have to create the folder).
                  4. I speciy my Web Application URL: http://localhost
                  5. I click the Finish button.

                  Note... I've already selected my Connectivity using the Data Source Explorer (which is available by selecting the following in Flex Builder: Windows, Otherviews, Connectivity, Data Source Explorer, and then adding in a database connection at my MS SQL 2005 server, specifying username and password).

                  6. Next, from Flex Builder, I select: Data, Create Application from Database, and specify the current project, connection (in my case, Northwind) and the employee table, etc. I click NEXT.
                  7. I can select C# with web services or Visual Basic with Web Services, so I select Visual Basic.
                  8. Select Finish.

                  OK at this point, a lot of code (action script, webservices, etc. is auto-generated for me - kewl.. just like Dreamweaver :-)

                  Now I'm ready to run the application.

                  But wait - I know it won't run because I note that the ASP .NET Development Server is not running. However - I can start it from the windows command line.

                  First thing I do is stop my local IIS server which is using Port 80.
                  Next thing I do is open a windows command line and navigate to my .Net 2.0 Framework directory:

                  cd \WINDOWS\Microsoft.NET\Framework\v2.0.50727

                  and then I run the ASP .NET Web server at the same path that my application (above) is written to (again, typed in the command line window).

                  start /b webdev.webserver /port:80 /path:"D:\Flex3 Projects\TestProj3\bin"

                  Finally, from the Flex Builder window, I right-click on the auto-build Employee.mxml table and select 'Run application'.

                  After a few moments an Internet Explorer window comes up. I believe it says:


                  and I change it to read:


                  and it runs.. well it runs, but with 'An unexpected error occured and it has been logged.'

                  So that's as far as I have gotten but it does write the code.


                  So am I to assume that whether I do this by hand or use the 'auto-generated code' that I will be using WebServices to read and write from the MS SQL 2005 database?

                  I would much rather my Flex Application open a connection to the database directly and send SQL statements. I'm guessing that might not be possible without some driver? Perhaps thats were Adobe Live Cycle comes in?

                  Any insight (frm anyone) would be helpful. Thank you.
                  • 6. Re: Populate Datagrid from database
                    Hi Gregory,

                    To run it manually I think you should type something like:
                    start /b webdev.webserver /port:80 /path:"D:\Flex3 Projects\TestProj3\

                    and run it from http://localhost/bin/Employees.html.

                    Now the strange thing is why Flex Builder doesn't detect your .NET Development Server. Maybe we have a problem here. Can you take a look in your workspace .matadata/.log file if there are any errors?

                    About accessing the DB directly from Flex, this is a big security hole so we don't advice anyone to do this. Remember that your flex app would be running on a lot of client's computers and it's like a web page., everyone can look into code (well it's compiled but still there are means to look what under the hood).

                    I would appreciate if can help us figure out why we don't find the WebDev server as it might happen under certain circumstances for other users too.

                    • 7. Re: Populate Datagrid from database
                      GregoryWexler Level 1
                      Hi Miti -

                      I have found that when I run the .NET Development Server, I also need to include the \bin directory in order for it to work. Without it, I get HTTP Error 403 - Forbidden. (using IE 6). I error even if I run it from http://localhost/bin/Employees.html as you've suggested.

                      So, using:
                      start /b webdev.webserver /port:80 /path:"D:\Flex3 Projects\TestProj3\bin"
                      and running it from
                      seems to bring up the page.

                      There are three specific errors listed in the log:

                      !SESSION 2007-10-05 10:44:05.421 -----------------------------------------------
                      java.vendor=Sun Microsystems Inc.
                      BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
                      Command-line arguments: -os win32 -ws win32 -arch x86

                      !ENTRY org.eclipse.jface 4 0 2007-10-05 10:44:09.062
                      !MESSAGE The command ("com.adobe.flexbuilder.exportimport.flexprojectexportaction") is undefined

                      !ENTRY org.eclipse.jface 4 0 2007-10-05 10:44:09.109
                      !MESSAGE The command ("com.adobe.flexbuilder.exportimport.skinartworkimportaction") is undefined

                      !ENTRY org.eclipse.jface 4 0 2007-10-05 10:44:09.109
                      !MESSAGE The command ("com.adobe.flexbuilder.exportimport.webserviceimportaction") is undefined

                      -- Gregory