Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8640999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:24:54+00:00 2026-06-12T11:24:54+00:00

Sorry im new.. I have 2 tables in my database: User and Account, I

  • 0

Sorry im new.. I have 2 tables in my database: User and Account, I have successfully add data to database.I want to retrieve data from the account table and display it to a list view. But it is not working. But after editing the code and try to retrieve data for the user it display correctly in the list view but it does not work for the account table. I don’t know where the error is. Can you help please. thanks
DatabaseAdapter.java

//User Table
public static final String KEY_ROWID = "_id";
public static final String KEY_UNAME = "name";
public static final String KEY_USURNAME = "surname";
public static final String KEY_UUSERNAME = "username";
public static final String KEY_UPASSWORD = "password";
public static final String KEY_UEMAILADDRESS = "emailadd";

//Account Table
public static final String KEY_ROWID1 = "_id";
public static final String KEY_BANKNAME =" bankname";
public static final String KEY_TYPE = " type";
public static final String KEY_ACCNUM = " accnum";
public static final String KEY_BALANCE = " balance";
public static final String KEY_EXPIRYDATE = " expirydate";

private static final String DATABASE_NAME = "MoneyManagerSys";
public static final String DATABASE_TABLE = " Usertb";
public static final String DATABASE_TABLE1 = " Accounttb";
private static final String DATABASE_TABLE2 = " Transactiontb";
private static final String DATABASE_TABLE3 = " BillRemindertb";
//Database Version
private static final int DATABASE_VERSION = 1;
private static String Usertb;
private static String Accounttb;
    private DbHelper MHelper;
private final Context MContext;
private SQLiteDatabase Mdatabase;

private static final String DATABASE_USER_TABLE = "CREATE TABLE" + DATABASE_TABLE + "  (" +
        KEY_ROWID + " INTEGER PRIMARY KEY, " +
        KEY_UNAME + " TEXT , " +
        KEY_USURNAME + " TEXT , " +
        KEY_UUSERNAME + " TEXT , " +
        KEY_UPASSWORD + " TEXT , " +
        KEY_UEMAILADDRESS + " TEXT );" ;

private static final String DATABASE_ACCOUNT_TABLE1 = "CREATE TABLE" + DATABASE_TABLE1 + " (" +
        KEY_ROWID1 + " INTEGER PRIMARY KEY, " +
        KEY_BANKNAME + " TEXT , " +
        KEY_TYPE + " TEXT , " +
        KEY_ACCNUM + " TEXT , " +
        KEY_BALANCE + " TEXT , " +
        KEY_EXPIRYDATE + " TEXT  );" ;

       public long createEntry1(String bankname, String type, String accnum, String balance, String expirydate) {
    ContentValues cv1 = new ContentValues();
    cv1.put(KEY_BANKNAME, bankname);
    cv1.put(KEY_TYPE, type);
    cv1.put(KEY_ACCNUM, accnum);
    cv1.put(KEY_BALANCE, balance);
    cv1.put(KEY_EXPIRYDATE, expirydate);
    return Mdatabase.insert(DATABASE_TABLE1, null, cv1);
}

public long createEntry(String name, String surname, String username, String password, String emailadd) {
    // TODO Auto-generated method stub
    ContentValues cv = new ContentValues();
    cv.put(KEY_UNAME, name);
    cv.put(KEY_USURNAME, surname);
    cv.put(KEY_UUSERNAME, username);
    cv.put(KEY_UPASSWORD, password);
    cv.put(KEY_UEMAILADDRESS, emailadd);
    return Mdatabase.insert(DATABASE_TABLE, null, cv);
}


public String getData() {
    // TODO Auto-generated method stub
    String[] columns = new String[] {KEY_ROWID, KEY_UNAME, KEY_USURNAME, KEY_UUSERNAME, KEY_UPASSWORD, KEY_UEMAILADDRESS};

    Cursor c = Mdatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);

    String result="";
    int iRow = c.getColumnIndex(KEY_ROWID); 
    int iUname = c.getColumnIndex(KEY_UNAME);   
    int iUsurnamne = c.getColumnIndex(KEY_USURNAME);    
    int iUuserpassword = c.getColumnIndex(KEY_UPASSWORD);   
    int iEmailAdd = c.getColumnIndex(KEY_UEMAILADDRESS);    

    for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
        result = result + c.getString(iRow) + " " + c.getString(iUname) + " " + c.getString(iUsurnamne) + " " + c.getString(iUsurnamne) + " " + c.getString(iUuserpassword) + " " + c.getString(iEmailAdd) + "\n";
    }
    return result;
}

 public boolean Login(String username, String password) throws SQLException  
    {  
        Cursor mCursor = Mdatabase.rawQuery("SELECT * FROM " + DATABASE_TABLE + " WHERE username=? AND password=?", new String[]{username,password});  
        if (mCursor != null) {  
            if(mCursor.getCount() > 0)  
            {  
                return true;  
            }  
        }  
     return false;  
    }  

  public Cursor fetchListItems() {

        Cursor cursor1 = Mdatabase.query(DATABASE_TABLE1, new String[] 
                      { KEY_ROWID1, KEY_BANKNAME, KEY_ACCNUM, KEY_BALANCE}, 
                      null, null, null, null, null);

        if (cursor1 != null) {
            cursor1.moveToFirst();
        }
        return cursor1;
    }
  }

TransactionListView.java

        public class TransactionListView extends ListActivity {


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.translistview);
        DatabaseAdapter dbHelper = new DatabaseAdapter(this);
        dbHelper.open();

        // Get a Cursor for the list items
        Cursor listCursor = dbHelper.fetchListItems();
        startManagingCursor(listCursor);

        // set the custom list adapter
        setListAdapter(new MyListAdapter(this, listCursor));
    }

    private class MyListAdapter extends ResourceCursorAdapter {

        public MyListAdapter(Context context, Cursor cursor) {
            super(context, R.layout.list_item_with_description, cursor);
        }

        @Override
        public void bindView(View view, Context context, Cursor cursor1) {

            TextView title = (TextView) view.findViewById(R.id.item_title);
            title.setText(cursor1.getString(
                        cursor1.getColumnIndex(DatabaseAdapter.KEY_BANKNAME)));

            TextView details = (TextView) view.findViewById(R.id.item_details);
            StringBuffer detailsText = new StringBuffer();

            int price = cursor1.getInt(cursor1.getColumnIndex(DatabaseAdapter.KEY_ACCNUM));
            if (price > 0){
                detailsText.append("Rs"+price+".00");
            } else {
                detailsText.append("Price Unavailable");
            }
            String description = cursor1.getString(cursor1.getColumnIndex(
                                                    DatabaseAdapter.KEY_BALANCE));
            if (description != null && description.length() > 0){
                detailsText.append(", "+description);
            }
            details.setText(detailsText.toString());

        }

    }

}

ERROR:

   10-07 16:23:10.437: E/CursorWindow(13987): Bad request for field slot 0,-1. numRows = 3,        numColumns = 4
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:24:55+00:00Added an answer on June 12, 2026 at 11:24 am

    first of all, provide the full stack not just the single line of error.

    second, it’s a good beginning if you removed the spaces out of the fields’ names constants. it’s just a bad idea to take spaces in strings that lightly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, but I'm new to accessing return from another domain. I have this url
here i tried to take name and password from database if the user have
So I have a php page that gets data from database and displays a
Sorry I am very new to open graph and have been having difficulty to
Sorry, I'm new to flash I have this line of code: BaseEntry( _entryList[i] ).topTeamName
I am new to javascript so sorry I don't know very much. I have
I am new to the asp.net, and sorry for grammar mistakes. I have 3
I have a relational database with three tables. The first containts id's that relate
My idea: I have a database of users, each user has an autoincremented id
I have a SQLite database that is created by reading some data in PDF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.