Android Question ANDROID QUERY

Gabriel Sam

New Member
Licensed User
rs.setDatabase("SAM,1433","CCPoSRestaurant","sa","96241822726890838")
rs.Query("Select * From Login where Password = '" & txtPin.Text & "'")
Msgbox(rs.TableList,"")
If LastException.IsInitialized=False Then
Msgbox("Invalid Pin","")
Else
For i = 0 To lv.Size
Msgbox(lv.Get(i),"")
Next
i NEED TO CHECK WHETHER THE ABOVE CODING IS CORRECT FOR SEARCH PASSWORD.
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
i NEED TO CHECK WHETHER THE ABOVE CODING IS CORRECT FOR SEARCH PASSWORD.
in fact it is false : you have to count from the Login database where the login and password do match
SELECT COUNT FROM Login WHERE ....

If you get 0 then Login and Password don't match. If you get 1 then its ok
 
Upvote 0

Gabriel Sam

New Member
Licensed User
Thanks for the Reply.
I have typed the Code
Dim cnt As Int

rs.setDatabase("SAM,1433","CCPoSRestaurant","sa","96241822725842541")
cnt = rs.Query("SELECT COUNT FROM Login WHERE password = '" & txtPin.Text & "'")
Msgbox(cnt,"")
But I am not getting the Message Box . Please Advice.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Gabriel Sam

New Member
Licensed User
The above tutorial use to open the db file, but my Database is on Server Sam.1433. And I got stuck on Line
cnt=rs.query("SELECT COUNT ....
Please Help ....
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The above tutorial use to open the db file, but my Database is on Server Sam.1433. And I got stuck on Line
You can not connect to a remote database using the sql object. It is only for connecting to a sqlite database on the device.

To connect to a remote database you need to setup an RDC (Remote DatabaseConnector). jRDC2 is the newest release.
Search the forum for jRDC2
It is a B4J app which you must run on your server. See the RDC tutorial onn how to connect to your RDC and get data from your DB.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
You can not connect to a remote database using the sql object. It is only for connecting to a sqlite database on the device.
I think he is using the MSSQL library located here. I'm just guessing though, since not a lot of info is given by the originating author. If that's the case, the first post on the library page has the following code fragment:
B4X:
db = setDatabase("Server IPNUMBER (not name)","databasename","username","password")
With some code fragments in other posts showing:
B4X:
a.setDatabase("IPADDRESS\SQLEXPRESS:port","DATABASENAME","USERNAME","PASSWORD")
So first of all I don't think the author is able to connect, since the connection string is not correct.

Also, @Erel says the following several times in that particular library thread:
the correct solution is to avoid using the library.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
rs.setDatabase("SAM,1433","CCPoSRestaurant","sa","96241822726890838")
I hope you just didn't post the real SA credentials for the MSSQL database you're working on. Just saying...
 
Upvote 0
Top