B4J Question [BVAD3] MySQL insert to a table issue

John Naylor

Active Member
Licensed User
Longtime User
B4j - 9.8
BANano - 7.37
BANanoVuetifyAD3 - 7.34
OpenJDK - 11.0.1

I've been working through the Mashy Teaches thread and everything has seemed fairly straight forward until now.

I have a WAMP server set up and a MySQL database that I can connect to and the SignIn app runs great right up to the point where I try to add a new row to the users table.

The Select works fine and I get Success = True when checking to see if the email address has already been entered but when it hasn't and my code tries to go through the process of inserting the emailaddress and password fields I don't seem to be able to manage it.

Here's my code from that part of the class...

B4X:
Private Sub registerDS_Create (Success As Boolean, Response As String, Error As String, affectedRows As Int, Result As List)
  
         Log ("Register Create")
        Log ("success - " & Success)
        Log ("Result - " & Result)
      
        If Success Then
            vuetify.ShowSwalToastError ("IT WORKED!!!!!", 1500)
        Else
            vuetify.ShowSwalToastError ("FFS WHAT IS GOING ON!?!?!?! ARRRRRGGGGGHHHHHHHHH!!!!!", 1500)
        End If
  
End Sub

Private Sub registerDS_SelectWhere (Success As Boolean, Response As String, Error As String, affectedRows As Int, Result As List)
    logindialog.UpdateLoading (login, False)

    If Success Then 'The database query worked so lets see if anything came back
        Log ("Success on the WHERE bit")
        If Result.Size = 0 Then
            Log ("email didn't exist so add this new user!")
          
            'Hash the username & password again
            Dim user As Map = login.GetData ("user")
            Dim semailaddress As String = user.Get("emailaddress")
            Dim spassword As String = user.Get ("password")
            'Create hash
            Dim userhash As String = vuetify.Md5Hash (semailaddress, spassword, False)
          
            user.Put ("password", userhash)
          
            'Database stuff
            registerDS.CREATE_MODE                'Tell the system we're creating a new record
            registerDS.SET_RECORD (user)         'Tell the system what the data will be to put in the database
            registerDS.CREATE                            'Actually create the new record
                                                                       'which will fire the registerDS_Create callback
        Else
            'Show an error toast (email address is already in the database)
            vuetify.ShowSwalToastError ("You've already signed up!", 1500)
        End If
    End If

The registerDS_Create sub gets called but never with Success = True

Any ideas where I should be looking?

Console log from Chrome

DevTools failed to load source map: Could not load content for http://localhost/learn2/scripts/index.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
bananovuetifyad3.js:353816 It is now recommended to add the 'beforeUnload' event to trap App life cycle!
_B.initialize @ bananovuetifyad3.js:353816
init @ app.js:21
banano_ready @ app.js:610
(anonymous) @ app.js:2405
favicon.ico:1 GET http://localhost/learn2/assets/favicon.ico 404 (Not Found)
app.js:380 ■[viewLogin: 159] 68e271b8ef7a0bcc707c621ef1f2c194
app.js:382 ■[viewLogin: 160] test@test.com
app.js:384 ■[viewLogin: 161] Password!
app.js:425 ■[viewLogin: 191] Success on the WHERE bit
app.js:429 ■[viewLogin: 193] email didn't exist so add this new user!
app.js:399 ■[viewLogin: 175] Register Create
app.js:401 ■[viewLogin: 176] success - false
app.js:403 ■[viewLogin: 177] Result -


My registerDS settings look like this (I know I've changed the database name from the course)
 

Attachments

  • Capture.JPG
    Capture.JPG
    44.5 KB · Views: 131
Last edited:
Solution
Hi. Start by correcting the 'field names on table' property. You are supposed to use semicolon and not a colon to separate the fields.
Top