+ Start a Discussion

Flex Login Problem

I'm trying to do some work with Flex, but am unable to login in.  I use this sample code from the Salesforce documentation:


<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication applicationComplete="init()" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:salesforce="http://www.salesforce.com/"> <salesforce:AIRConnection id="force" /> <mx:DataGrid id="mygrid" right="10" left="10" top="10" bottom="10"> </mx:DataGrid> <mx:Script> <![CDATA[ import com.salesforce.results.QueryResult; import com.salesforce.results.LoginResult; import com.salesforce.AsyncResponder; import com.salesforce.objects.LoginRequest; private function init():void{ var lr:LoginRequest = new LoginRequest(); lr.username = "xxxxxxxxxxx.com"; lr.password = "xxxxxxxx"; lr.callback = new AsyncResponder(loadGrid); force.login(lr); } private function loadGrid(lr:LoginResult):void{ force.query("Select Id, FirstName, LastName From Contact", new AsyncResponder( function(qr:QueryResult):void { mygrid.dataProvider = qr.records; }) ); } ]]> </mx:Script> </mx:WindowedApplication>



(UserId and password have been masked).


However, when I run this, I get the following errors in the console:


[SWF] demo.swf - 1,551,231 bytes after decompression

offline but we will succeed at logging in anyways

query - offline

Error: Error #3104: A SQLConnection must be open to perform this operation.


This is followed by a list of subsequent problems caused by the lack of connection.


I've tried most of the other sample code as well and always end up with essentially the same problem - the app loads, but there is no data visible.  It feels like there must be something wrong somewhere in my setup.


Can anyone tell me what I'm missing here?


Thanks for your help.



have you appended your security token to your password?