yes i have the soln:
                           selectStmt.text = "insert into  widgetdef
(id,code,name,widgetdefgroup, image) values
('"+Number(id)+"','"+String(widgetCode)+"','"+String(widgetName)+"','"+String(widgetDefGroup)+"',
'"+new File("http://www.helpexamples.com/flash/images/image1.jpg";) +"') ";

try to give like this. instead of assign the values.

var sqlInsert:String = "INSERT INTO Person1 (id, firstName)"

"values("+_id +"','"+ _name+ ")";


On Sun, Nov 15, 2009 at 8:57 PM, Srinivasan Sudharsanam <
[email protected]> wrote:

> Hi
>
> When i click Submit Button Id and Firstname field display in datagrid.
> ID should be auto increment.
>
> When i click button error display:
>
> QLError: 'Error #3115: SQL Error.', details:'near ";": syntax error',
> operation:'execute'
>
> Anyone can pls fix it......
>
> <?xml version="1.0" encoding="utf-8"?>
>
> <mx:WindowedApplication
>
> xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute"
> preinitialize="init()"
>
> >
>
>
> <mx:Script>
> <![CDATA[
>
>
> import mx.controls.Alert;
>
>
>
> private var exampleDB:SQLConnection;
>
> private var dbStatement:SQLStatement;
>
> private var exampleDBFile:File;
>
>
> private var _id:int;
>
>
> private var _name:String;
>
>
> [
>
> Bindable]
>
> private var personData:Array;
>
>
>
> private function init():void {
> initAndOpenDatabase()
>
>
> }
>
>
>
> private function initAndOpenDatabase():void {
>
> exampleDBFile = File.applicationStorageDirectory.resolvePath(
>
> "Person.db");
> exampleDB =
>
> new SQLConnection();
> exampleDB.addEventListener(SQLEvent.OPEN, onExampleDBOpened);
>
> exampleDB.addEventListener(SQLErrorEvent.ERROR, onExampleError);
>
> exampleDB.open(exampleDBFile);
>
> }
>
>
>
> private function onExampleDBOpened(event:SQLEvent):void {
>
>
> if(event.type == "open"){
> getRecords();
>
> }
>
>
> }
>
>
>
> private function getRecords():void {
>
>
> var sqlQuery:String = "CREATE TABLE IF NOT EXISTS Person1(id INTEGER
> PRIMARY KEY, " +
>
> "firstName TEXT NOT NULL)";
>
> dbStatement =
>
> new SQLStatement();
> dbStatement.sqlConnection = exampleDB;
>
> dbStatement.text = sqlQuery;
>
> dbStatement.addEventListener(SQLEvent.RESULT,
> onDBStatementSelectResult);
>
> dbStatement.execute();
>
> }
>
>
>
> private function addPersonToDatabase():void {
>
>
> if(firstName.text != "" ) {
>
> _id = 0;
>
> _name = firstName.text;
>
>
>
> if((exampleDBFile != null) && (exampleDBFile.exists)) {
>
>
> var sqlInsert:String = "INSERT INTO Person1 (id, firstName)"
>
> "values("+_id +"','"+ _name+ ")";
>
> dbStatement =
>
> new SQLStatement();
> dbStatement.sqlConnection = exampleDB;
>
> dbStatement.text = sqlInsert;
>
> dbStatement.removeEventListener(SQLEvent.RESULT,
> onDBStatementSelectResult);
>
> dbStatement.addEventListener(SQLEvent.RESULT,
> onDBStatementInsertResult);
>
> dbStatement.execute();
>
>
>
> }
>
>
> }
>
>
> }
>
>
>
>
>
> private function onDBStatementSelectResult(event:SQLEvent):void
> {
>
>
> var result:SQLResult = dbStatement.getResult();
>
> if (result != null)
> {
>
> personData = result.data;
>
> }
>
> }
>
>
>
> private function onDBStatementInsertResult(event:SQLEvent):void
> {
>
>
> if (exampleDB.totalChanges >= 1)
> {
>
> getRecords();
>
> }
>
> }
>
>
>
> private function onExampleError(event:SQLEvent):void {
> Alert.show(
>
> "Error event");
> }
>
>
>
> ]]>
>
>
> </mx:Script>
>
>
> <mx:HBox width="80%" height="100%" horizontalAlign="center">
>
>
>
>
> <mx:DataGrid id="dg1" width="100%" height="50%"
> dataProvider="{personData}">
>
>
>
>
> <mx:columns>
>
>
>
>
> <mx:DataGridColumn id="idCol" width="50" dataField="id"
> headerText="Id" textAlign="center"/>
>
>
>
>
> <mx:DataGridColumn id="nameCol" width="100" dataField="firstName"
>
> headerText="
>
> Name" textAlign="center"/>
>
>
>
>
>
>
> </mx:columns>
>
>
>
>
> </mx:DataGrid>
>
>
>
>
> </mx:HBox>
>
>
>
> <mx:VBox y="400">
>
>
>
> <mx:Form>
>
>
> <mx:FormItem label="Name">
>
>
> <mx:TextInput id="firstName"/>
>
>
> </mx:FormItem>
>
>
> <mx:FormItem label="Submit">
>
>
> <mx:Button label="Click Me" click="addPersonToDatabase()" />
>
>
> </mx:FormItem>
>
>
> </mx:Form>
>
>
> </mx:VBox>
>
> </mx:WindowedApplication>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<flex_india%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=.
>
>
>

--

You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=.


Reply via email to