Android Question MSSQL Database response

David Hawkins

Active Member
Licensed User
Longtime User
I am using the JdbcSQL connector to an SQL Database which is working fine I can use select queries and update queries all working fine, however when I update a record using

B4X:
Main.MsSQL.ExecNonQuery2("update TblFarmFieldInformation set cattle = ?, breedingsheep = ?, drysheep = ?, other = ?, fieldnotes = ? where ID = ?", Array As Object(B4XFloatTextField1.text.Trim, B4XFloatTextField2.Text.trim, B4XFloatTextField3.Text.trim, B4XFloatTextField4.Text.trim, B4XFloatTextField5.Text.trim, IDValue))

the record is updated but when trying to get a true response back from the database by using

B4X:
Sub SQL_NonQueryComplete (Success As Boolean, Result As ResultSet)
    Try
        If Success Then

        Else
            ToastMessageShow("There was an error updating the field information",True)
        End If
    Catch
        Log(LastException)
    End Try
End Sub

the sub routine isn't even fired.

I'm obviously doing something wrong but I can't seem to work where the problem is.

Please help
 

DonManfred

Expert
Licensed User
Longtime User
ExecNonQuery2 does not raise an Event.

Use AddNonQueryToBatch for all insertqueries and then call ExecNonQueryBatch
B4X:
            For i = 1 To 1000
                sql.AddNonQueryToBatch("INSERT INTO table1 VALUES (?)", Array(Rnd(0, 100000)))
            Next
            Dim SenderFilter As Object = sql.ExecNonQueryBatch("SQL")
            Wait For (SenderFilter) SQL_NonQueryComplete (success As Boolean)
 
Upvote 1
Top