Android Question MSSQL INSERT INTO COMMAND NOT WORKING IN B4A 7.80

manuaaa

Member
Licensed User
Longtime User
Dear all,
Iam Using MSSQL Database in Backend and it is very well working in old versions of B4a but not working in B4a Version 7.80 and my code is mention below :
B4X:
Sub Activity_Create(FirstTime As Boolean)
a.setDatabase("ip address","database","userid","Password")
    Activity.LoadLayout("Login")
End Sub

after successfull login i called a new activity called 'Lyloggedin' and from there iam trying to insert some data in a table with the help of two textboxes and one command button. But data is not inserting in table also it didn't shows any error in the codes. My codes are given below :
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals

    Private Ename As Label
    Private Lage As Label
    Private Tname As EditText
    Private Tage As EditText
    Private Sdata As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    Activity.LoadLayout("Lyloggedin")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Sdata_Click
    If Tname.text = "" Then
        Msgbox("Please Enter Name","")
        Return
    
    Else
        Dim OP As String
        OP = Main.a.Query("INSERT INTO testnew (Name, Age) OUTPUT Inserted.ID VALUES(" & Tname.Text &", "& Tage.Text &")SELECT SCOPE_IDENTITY()")
        OP = ""
    
        Msgbox("Data Submitted Successfully","")
    End If
End Sub

Now iam getting confused because same code is already running in old versions of B4A. Then why it is not inserting data from latest version.
For that i tested it once again and found that we call data , view data and delete data but the only thing which is not working is , it can't insert data. why?..
Is there any one to help me...
 

OliverA

Expert
Licensed User
Longtime User
What library are you using to access MSSQL? Also, B4A 7.8 seems old too.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
maybe missing a ; before select?
at name i would expect ' around the string value.
a good test tool is ms management studio. copy the Query string and try it there.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top