query database for LOGIN information- username and password

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

query database for LOGIN information- username and password

Postby Tunwiir » Wed Nov 18, 2009 3:10 am

hi there,
I am writing a login screen for android. i have managed to create the database and inserted some users. My problem now is i want to query the database when the user clicks on login from the main menu.
What the query needs to do is check whether the username typed by the user exists in the database. I am having some problems with this and all your help is much appreciated.

below is the source code from my DBAdapter class.. thanks very much

//---retrieves a particular user---
public Cursor getUser(String username) throws SQLException
{


Cursor mCursor=db.rawQuery("SELECT name FROM" +DATABASE_NAME+"WHERE user_name="+username+";", null);

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

When i call this from my main class it just crashes.

Hope to hear form you guys soon
Tunwiir
Tunwiir
Freshman
Freshman
 
Posts: 6
Joined: Tue Aug 11, 2009 2:52 pm
Location: Manchester

Top

Postby nmc » Wed Nov 18, 2009 10:14 am

"SELECT name FROM" +DATABASE_NAME+"WHERE user_name="+username+";"

Try: "SELECT name FROM " + DATABASE_NAME + " WHERE user_name='"+username+"'"
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Query database for LOGIN information- username and password

Postby Tunwiir » Wed Nov 18, 2009 10:26 am

Hi and thanks for taking time to help.
i tried what u suggested but still same problem.

i have attached the two files for you to have a look at..
your help is much appreciated..
Regards
Tunwiir
Attachments
MainLogin.java
(2.76 KiB) Downloaded 48 times
DBAdapter.java
(3.28 KiB) Downloaded 46 times
Tunwiir
Freshman
Freshman
 
Posts: 6
Joined: Tue Aug 11, 2009 2:52 pm
Location: Manchester

Postby nmc » Wed Nov 18, 2009 11:41 am

i tried what u suggested but still same problem.

Then maybe DATABASE_NAME is indeed what the name suggests and should be TABLE_NAME instead.
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

query database for LOGIN information- username and password

Postby Tunwiir » Wed Nov 18, 2009 11:50 am

Thanks very much..
i was so concerned with the actual syntax that i overlooked the basics..:(

thanks again for your time
Tunwiir
Tunwiir
Freshman
Freshman
 
Posts: 6
Joined: Tue Aug 11, 2009 2:52 pm
Location: Manchester

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 6 guests