B4J Question Jrdc Parameters

elitevenkat

Active Member
Licensed User
Longtime User
i am ale to run rdc server and client example successfully.
with following code
B4X:
Sub AppStart (Form1 AsForm, Args() AsString)
 MainForm = Form1'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file. MainForm.Show
 TableView1.Initialize("TableView1")
 MainForm.RootPane.AddNode(TableView1, 0, 0, 0, 0)
 MainForm.RootPane.SetAnchors(TableView1, 0, 0,0, 0) 'fill the screen reqManager.Initialize(Me, "http://127.0.0.1:17178/rdc")
 GetAnimal("test")End SubSub GetAnimal(Name AsString)Dim cmd As DBCommand
 cmd.Initialize
 cmd.Name = "select_animal"
 cmd.Parameters = ArrayAs Object(Name)
 reqManager.ExecuteQuery(cmd, 0, Null)End Sub'the server side sql issql.select_animal=SELECT name, image, pkey FROM animal where name ?

if i want to check like this in server side
B4X:
sql.select_animal=SELECT name, image, pkey FROM animal where name like ? and pkey=?

how do i pass the 2nd parameter value from my code ?
i tried like this

B4X:
GetAnimal("(%, 1)")
got error : Error: java.sql.SQLException: No value specified for parameter 2

kindly help
 

billzhan

Active Member
Licensed User
Longtime User
You are passing the string "(%, 1)" to the first argument of SQL statement which expects Array(2) of Object

B4X:
Sub GetAnimal(Name As String, pkey as string)
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "select_animal"
cmd.Parameters = Array As Object("%"&Name&"%",pkey)
reqManager.ExecuteQuery(cmd, 0, Null)
End Sub
 
Last edited:
Upvote 0
Top