2013-11-25 2 views
0

이 코드를 사용하여 로컬 sqlite 데이터베이스에 대한 새 레코드를 만들려고 시도 중입니다.이 코드는 이지만 dosect 작업은 저장을 클릭하면이 오류가 발생합니다.1067 : Class 유형의 값을 관련없는 유형으로 암시 적으로 변환합니다.

1120 : Access of undefined property sqlConnection.

이 내가 데이터베이스에 레코드를 저장하려고 EmployeeDAO

  public static function create(employee:Employee):void 
    { 

    var sql:String = "INSERT INTO words (id, term, defin, term1, defin1) " + 
      "VALUES (?,?,?,?,?)"; 
     var stmt:SQLStatement = new SQLStatement(); 
     stmt.sqlConnection = sqlConnection; 
     stmt.text = sql; 

     stmt.parameters[1] = employee.term; 
     stmt.parameters[2] = employee.defin; 
     stmt.parameters[3] = employee.term1; 
     stmt.execute(); 
     employee.loaded = false; 
    } 

add.mxml 내 방법입니다

import model.Employee; 
    import model.EmployeeDAO; 

     protected function onSave():void { 

      var newEmployee:Employee = new Employee(); 
      newEmployee.term = term.text; 
      newEmployee.defin = defin.text; 
      newEmployee.term1 = term1.text; 
      newEmployee.defin1 = defin1.text; 
      EmployeeDAO.create(newEmployee); 
      navigator.popView(); 
     } 
    ]]> 
</fx:Script> 

<s:actionContent> 
    <s:Button label="Save" click="onSave()"/> 
</s:actionContent> 

<s:layout> 
    <s:VerticalLayout paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10"/> 
</s:layout> 

<s:Label text="term"/> 
<s:TextInput id="term" width="100%"/> 

<s:Label text="defin"/> 
<s:TextArea id="defin" width="100%" height="200"/> 

<s:Label text="term1"/> 
<s:TextInput id="term1" width="100%"/> 

<s:Label text="defin1"/> 
<s:TextArea id="defin1" width="100%" height="200"/> 

답변

0

클래스를 인스턴스화하지 않고 함수를 호출하려면 함수를 정적으로 선언해야합니다. 그럼 그게 작동합니다

public static function create(employee:Employee):void 
+0

나는 그것을 시도하고 첫 번째 게시물을 확인 다른 오류가있어 – sayydo

+0

물론 오류가 발생합니다. 코드에 따라 sqlconnection은 정의되지 않습니다. 정적 함수 외부에 sqlConnection을 정의한 경우 정적으로 정의해야합니다. – Sumit

+0

하지만 두 번 이상 정의 할 수 없습니다. "public function get sqlConnection() : SQLConnection" – sayydo

관련 문제