Ayabonga Member Nov 19, 2020 #1 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. Code: Copy Dim cmd As DBCommand = CreateCommand("save", Array As String(Remytxt.Text, Hennytxt.Text, Sodatxt.Text,Starter.Username,Starter.Password)) Code: Copy sql.save =INSERT INTO history(Remy, Henny, Soda) VALUES (?, ?, ?) SELECT * FROM users WHERE Username = ? AND Password = ?
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. Code: Copy Dim cmd As DBCommand = CreateCommand("save", Array As String(Remytxt.Text, Hennytxt.Text, Sodatxt.Text,Starter.Username,Starter.Password)) Code: Copy sql.save =INSERT INTO history(Remy, Henny, Soda) VALUES (?, ?, ?) SELECT * FROM users WHERE Username = ? AND Password = ?
Erel B4X founder Staff member Licensed User Longtime User Nov 20, 2020 #2 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. Upvote 0
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.
Ayabonga Member Nov 20, 2020 #3 Erel said: 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. Click to expand... 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
Erel said: 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. Click to expand... 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.
OliverA Expert Licensed User Longtime User Nov 22, 2020 #4 Try Code: Copy 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
Try Code: Copy 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
Erel B4X founder Staff member Licensed User Longtime User Nov 22, 2020 #5 Ayabonga said: . 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. Click to expand... You will call req.ExecuteQuery, get the value that you need and later use it when you insert data. Upvote 0
Ayabonga said: . 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. Click to expand... You will call req.ExecuteQuery, get the value that you need and later use it when you insert data.