Array as string (value) error

Dman

Active Member
Licensed User
Longtime User
I am trying to compile this code and it is giving me an error. I adjusted the code from the DBUtils program but I obviously am not doing it correctly and I can't see where it is not correct.

Here is the code. I put it into the activity_create sub and all I want it to do is populate editboxes with the only field in the table when the activity loads.



B4X:
Dim m As Map


      m = DBUtils.ExecuteMap(SQL1, "SELECT companynumber, companyname, companystreet, companycity, companystate, companyzip, companyphone1, companyphone2 FROM company WHERE companynumber = ?", Array As String(value))
      If m.IsInitialized = False Then      
      Msgbox("No information found.","")
   Else
      txtNumber.Text = m.Get("companynumber")
      txtName.Text = m.Get("companyname")
      txtAddress.Text = m.Get("companystreet")
      txtCity.Text = m.Get("companycity")
      txtState.Text = m.Get("companystate")
      txtZip.Text = m.Get("companyzip")
      txtPhone1.Text = m.Get("companyphone1")
      txtPhone2.Text = m.Get("companyphone2")'keys are lower cased!
   End If

And here is the error I get. I know that in the DBUtils program, the declaration of the value is stated in the sub for the spinner (which is: Sub spnrStudentId_ItemClick (Position As Int, Value As Object) but when I try that, the app compiles but when I start that activity on the phone, it gives me an error stating that the signature received was not what was expected or something like that.



B4X:
Compiling code.                         Error
Error parsing program.
Error description: Undeclared variable 'value' is used before it was assigned any value.
Occurred on line: 35
m = DBUtils.ExecuteMap(SQL1, "SELECT companynumber, companyname, companystreet, companycity, companystate, companyzip, companyphone1, companyphone2 FROM company WHERE companynumber = ?", Array As String(value))
 

Merlot2309

Active Member
Licensed User
Longtime User
Hello,

When you Dim someString as String in Globals, add someString=value in the spinner_Click and change value to someString in the ExecMap line it should work fine.

Succes,
Helen.
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
Thank you for the reply. I created a variable and made it equal 1 and used the variable for the value and it seems to work.

So the value needs to be what the ? in the statement is supposed to be?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…