0 Replies Latest reply on Aug 18, 2016 6:57 AM by Androiddeveloper

    I can not delete database operation?where  do i have error?

    Androiddeveloper

      Hello

      I can't delete database operation.i wrote  delete database queries kind of 3 format codes.source code 1:

       

       

      protected function buton_clickHandler(event:MouseEvent):void   {
        
      // TODO Auto-generated method stub
        
      function seckayit():void{
        
      var sec:SQLStatement=new SQLStatement;
        sec
      .sqlConnection=conn;
        sec
      .text="SELECT * FROM deneme";
        sec
      .execute();
        sec
      .addEventListener(SQLEvent.RESULT,silkayit);
        
      function silkayit(event:SQLResult):void{
        stmt
      .sqlConnection = conn;
        stmt
      .text="";
        
      //contactList.removeAll();
        stmt
      .text="DELETE FROM deneme WHERE id='"+liste.selectedItem.id+"'";  

        stmt
      .execute();

        
      }

        
      }
        
      }

       

      that's The source code 2:

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

        xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView" contentCreationComplete="{selectContacts()}">

        <fx:Script source="../sec.as"/>

        <fx:Script>

        <![CDATA[

        import spark.events.GridSelectionEvent;

        import spark.events.IndexChangeEvent;

                protected function liste_changeHandler(event:IndexChangeEvent):void

        {

        // TODO Auto-generated method stub

        buton.enabled=true;

        }

        protected function silkayit(event:MouseEvent):void{

        var sec:SQLStatement=new SQLStatement;

        sec.sqlConnection = this.isDbConnected(conn);

        sec.text="SELECT * FROM deneme";

        sec.execute();

         

        var i:int=0;

        var data1:Array=sec.getResult().data;

        var row:Object=data1.data;

        var rid:int=row.sid;

       

        var stmt1:SQLStatement=new SQLStatement;

        stmt1.sqlConnection = this.isDbConnected(conn);

       

        

        //contactList.removeAll();

        stmt1.text="DELETE FROM deneme where id='"+liste.selectedItem.rid+"'";

       

        stmt1.execute();

        }

       

        ]]>

        </fx:Script>

       

        <fx:Declarations>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

        </fx:Declarations>

       

      <s:List id="liste" width="300" height="253" change="liste_changeHandler(event)"

        dataProvider="{contactList}" fontSize="12" horizontalCenter="0" labelFunction="displayFunc"

        selectedIndex="-1" verticalCenter="0">

       

       

        </s:List>

        <s:Button id="buton" x="206" y="-2" label="Kayıt Sil" click="silkayit(event)"   enabled="false"/>

       

      </s:View>

       

       

      Finally the source code 3 is:

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

        xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView" contentCreationComplete="{selectContacts()}">

        <fx:Script source="../sec.as"/>

        <fx:Script>

        <![CDATA[

        import spark.events.GridSelectionEvent;

        import spark.events.IndexChangeEvent;

        protected function liste_changeHandler(event:IndexChangeEvent):void

        {

        // TODO Auto-generated method stub

        buton.enabled=true;

        }

        protected function silkayit(event:MouseEvent):void{

       

        var stmt1:SQLStatement=new SQLStatement;

        stmt1.sqlConnection = this.isDbConnected(conn);

       

        

        //contactList.removeAll();

        stmt1.text="DELETE FROM deneme where id='"+liste.selectedItem.data.id+"'";

       

        stmt1.execute();

        }

       

        ]]>

        </fx:Script>

       

        <fx:Declarations>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

        </fx:Declarations>

       

      <s:List id="liste" width="300" height="253" change="liste_changeHandler(event)"

        dataProvider="{contactList}" fontSize="12" horizontalCenter="0" labelFunction="displayFunc"

        selectedIndex="-1" verticalCenter="0">

          </s:List>

        <s:Button id="buton" x="206" y="-2" label="Kayıt Sil" click="silkayit(event)"   enabled="false"/>

       

      </s:View>

       

       

      Although i have worked 3 formats,i could not run delete database operations.Where are my error?How must i write code correctly?i usuallay my error  below rows at:

        stmt1.text="DELETE FROM deneme where id='"+liste.selectedItem.data.id+"'";

        stmt1.text="DELETE FROM deneme where id='"+liste.selectedItem.rid+"'";

      stmt.text="DELETE FROM deneme WHERE id='"+liste.selectedItem.id+"'";

       

      Also when i have worked ,i have error below at:

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at views
      ::listviewHomeView/silkayit()[C:\Users\mobil-developer\Adobe Flash Builder 4.6\veri-islem\src\sec.as:68]
        at views
      ::listviewHomeView/___listviewHomeView_Button1_click()[C:\Users\mobil-developer\Adobe Flash Builder 4.6\veri-islem\src\views\listviewHomeView.mxml:16]

       

      my database is not null.What can i do?would you like to help me?