Android Question JRDC2 MYSQL COMMAND

Ayabonga

Member
Hello guys,

I have two tables from PhpMyadmin: Users table , History table. I want to insert 3 values into history table but according to user logged-in. The username and password must be selected from the users table. Can you please help me structure the sql command.
B4A CODE:
    Dim cmd As DBCommand = CreateCommand("save", Array As String(Remytxt.Text, Hennytxt.Text, Sodatxt.Text,Starter.Username,Starter.Password))
MSQL Command from B4J config file:
sql.save =INSERT INTO history(Remy, Henny, Soda) VALUES (?, ?, ?)
SELECT * FROM users WHERE Username = ? AND Password = ?
 

Ayabonga

Member
Not sure that it is not worth splitting it into two commands. It will be simple to implement and will allow you to show a meaningful error message if the username and password are wrong.
Thanks for the response. I am not really good at creating SQL commands. If I create these commands separately, the insert and select command, How will I integrate/join them to do what I'm trying to achieve.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Try
B4X:
sql.save =INSERT INTO history (Remy, Henny, Soda) SELECT ?, ?, ? WHERE (SELECT COUNT(Username) FROM users WHERE Username = ? AND Password = ?) <> 0
Note: May not work due to restrictions of where ? can be placed
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
. I am not really good at creating SQL commands. If I create these commands separately, the insert and select command, How will I integrate/join them to do what I'm trying to achieve.
You will call req.ExecuteQuery, get the value that you need and later use it when you insert data.
 
Upvote 0
Top