0

当用户输入教师姓名时,我需要搜索教师姓名并显示有关它的所有信息

我已经编写了这段代码,但它给了我运行时错误,这个错误是:FATAL EXCEPTION: main

这是 GetRecord 方法

 public Cursor getRecord(String n1) throws SQLException 
 {
      Cursor mCursor =db.query(true, databaseName, new String[] {facultyc,
                 deparmentc, namec, officeNumberc,Phonec ,emailAddressc,officeHourc},namec + "=" + n1, null, null, null, null, null);
      if (mCursor != null) {
           mCursor.moveToFirst();
      }
      return mCursor;
 }

和这个搜索方法,当用户点击搜索按钮时它的表现

public void search(){

    db.open();
    Cursor c = db.getRecord(n);
    if (c.moveToFirst()){
        t1.setText(c.getString(0));
        t2.setText(c.getString(1));
        t3.setText(c.getString(2));
        t4.setText(c.getString(3));
        t5.setText(c.getString(4));
        t6.setText(c.getString(5));
        t7.setText(c.getString(6));

    }

    else
        Toast.makeText(this, "this Dr not found", Toast.LENGTH_LONG).show();
    db.close();
}

出现这个错误

05-04 13:39:52.856: E/Trace(4001): 打开跟踪文件时出错: 没有这样的文件或目录 (2)

4

0 回答 0