2 Replies Latest reply on Jan 20, 2009 7:44 AM by Newsgroup_User

    CF needed to access an SQL database?

    Laurence MacNeill Level 1
      Ok. Someone please 'splain to me why I must use ColdFusion to access MS SQL data in Flex? And how? I just don't understand exactly why CF is needed. Why can't a Flex app simply open an SQL database file? Take, for example, an app written in, say, Perl. It simply opens the file and reads it -- why can't Flex do that? Why so many layers of complexity? I really don't understand why there are so many (seemingly unnecessary) layers of overly complex software to do something that really should be so simple...

      And secondly, assuming all these layers of complexity really are needed, exactly how does CF suddenly, magically enable my Flex app to read an SQL database? I'd really like some example code here -- what specific code do I need to write in my Flex app to get it to use CF's SQL data-source? (I'm assuming that in the CF's 'Admin -> Data & Services -> Data Sources' configuration page, I add a new data source, and then somehow my Flex app is magically connected to that source, yes?) But I'm just not seeing where that connection is, or how I can use it...

      Thanks for any help you can offer.
        • 1. Re: CF needed to access an SQL database?
          rtalton Level 4
          Flex does not require the use of Cold Fusion to access a MS SQL database. You can use .NET, for example, to retrieve the data for Flex. I've also used PHP/MySQL. Never used CF with Flex, and haven't found any need to. Flex doesn't know or care where your data come from. It is completely data agnostic.
          Having said that, Adobe has set up CF so that you can use remoting with it and Flex. Is this what you are trying to do?
          • 2. Re: CF needed to access an SQL database?
            Level 7

            "Laurence MacNeill" <webforumsuser@macromedia.com> wrote in message
            news:gl49ck$sl6$1@forums.macromedia.com...
            > Ok. Someone please 'splain to me why I must use ColdFusion to access MS
            > SQL
            > data in Flex? And how? I just don't understand exactly why CF is needed.
            > Why
            > can't a Flex app simply open an SQL database file? Take, for example, an
            > app
            > written in, say, Perl. It simply opens the file and reads it -- why can't
            > Flex
            > do that? Why so many layers of complexity? I really don't understand why
            > there are so many (seemingly unnecessary) layers of overly complex
            > software to
            > do something that really should be so simple...

            I think you're misunderstanding what happens with a normal backend page,
            whether it be cgi, asp, or coldfusion, retrieves data and presents it to the
            user.

            In a nutshell, here is what happens:

            1) Client (browser) contacts server with a request.
            2) Server calls up back end technology
            3) Back end technology establishes connection with database. It can do
            this, because it is on the server where the database lives, or has a direct
            network connection to that database.
            4) Back end technology queries database, receives a result.
            5) Back end technology formats result for client
            6) Client (browser) turns formatted result into something humans can read
            (if the developer has done her job right).

            When a browser is involved, each time you want something from the database,
            you have to redraw the entire interface (page refresh). There are ways to
            avoid this, but if you think Flex is complex, you'll run screaming from
            AJAX.

            What Flex is is essentially a second client that sits inside the browser
            which can communicate with the back end technology without having to refresh
            the page. This means that the user isn't constantly being interrupted by
            total redraws while he is trying to work. It also offers additional
            capabilities that aren't relevant to this discussion, such as animations and
            effects.

            > And secondly, assuming all these layers of complexity really are needed,
            > exactly how does CF suddenly, magically enable my Flex app to read an SQL
            > database? I'd really like some example code here -- what specific code do
            > I
            > need to write in my Flex app to get it to use CF's SQL data-source? (I'm
            > assuming that in the CF's 'Admin -> Data & Services -> Data Sources'
            > configuration page, I add a new data source, and then somehow my Flex app
            > is
            > magically connected to that source, yes?) But I'm just not seeing where
            > that
            > connection is, or how I can use it...

            I'm not much on ColdFusion, but I think that once you have that data source
            configured, you'll need to still write cfqueries on it and return the
            results as XML or typed objects.

            I have a question for you... This is not meant to be derogatory in any way,
            but more curious. How did you get tasked to do something that you don't
            have enough understanding to even know where you'd begin to start on it?

            -Amy