Android Question MySql, I need get data

macerau

Member
Licensed User
Longtime User
All I need is for the 3 lines work, below the yellow line !
I have already tried with list, map, JSONParser and I can not get the result, below in this example:

first time
LOG->RA
LOG->REGISTRO
second time
LOG->B0000264
LOG->0000000
third time
LOG->B0000182
LOG->0000013




but




Please Help me,
Show to me the way...
 

Attachments

  • f0.jpg
    f0.jpg
    17.4 KB · Views: 160
  • f1.jpg
    f1.jpg
    192.5 KB · Views: 170

OliverA

Expert
Licensed User
Longtime User
What is db.query? Code for that method?
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Well for starters at line 196 in your "ATUAL" activity, you have:
B4X:
M = db.Query(...)

There is no method "Query" in the database object. You should change it to:
B4X:
M = dq.ExecQuery(...)

Once you get past that, you can start to look at whatever other issues you might have.

- Colin.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

macerau

Member
Licensed User
Longtime User
You need to explain in more detail what you are trying to do..

Imagine a database with a table called "Mytab".
This table contains 2 records each record has two columns
ex: id name
01 Mary
02 John

Okay, what I need is to do a select on this table of type:
"select id, Name from MyTab"
is to put the table data in two variables of the type
dim id (2) as string
dim Nm (2) as string

in vb6 could be like this

id (1) = tb ("id")
Nm (1) = tb ("Name")
tb.movenext
id (2) = tb ("id")
Nm (2) = tb ("Name")

debug.print id(2)
02
debug.print Nm(2)
John

I would like this to work on b4a
 
Upvote 0

macerau

Member
Licensed User
Longtime User
You should use JdbcSQL if you want to directly connect to a MS SQL database.

It may seem like bullshit but that's exactly what I want and I can not get somebody out of a light

Imagine a database with a table called "Mytab".
This table contains 2 records each record has two columns
ex: id name
01 Mary
02 John

Okay, what I need is to do a select on this table of type:
"select id, Name from MyTab"
is to put the table data in two variables of the type
dim id (2) as string
dim Nm (2) as string

in vb6 could be like this

id (1) = tb ("id")
Nm (1) = tb ("Name")
tb.movenext
id (2) = tb ("id")
Nm (2) = tb ("Name")

debug.print id(2)
02
debug.print Nm(2)
John

I would like this to work on b4a




Could you in 5 to 10 program lines show how this really works?
because I arrive as you can see through the images until having the whole base inside a string
[01 Mary 02 John]
but for this I had to make a program to separate the data from there.
and I know it has a super simple form but I do not think
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
What is SQL1 in your code? A connection to the MS SQL database? A local (to the device) SQLite database?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Do you want to continue using the library your using for MS SQL access or do you want to switch to JdbcSQL? If you are going to switch to JdbcSQL, then any locally accessed SQLite database must also be managed by this library. The connection string for JdbcSQL is a tad different then for B4A's SQL library and there is no more Cursor (it's a ResultSet). W/JdbcSQL, there are two drivers for MS SQL access, a jTDS driver (here http://jtds.sourceforge.net/) and a MS SQL JDBC driver. The jTDS seems to be easier to set up, but may not work with newer MS SQL versions (may). The MS SQL version may not work on Android (at one time it did not due to defaulting to TLS/SSL that was not "compatible" with Android - or something like that). If you use JdbcSQL, if you look here (https://www.b4x.com/android/forum/threads/sql-tutorial.35185/) at @Erel's first post, you should have enough material to figure this out (it shows how to reference the database drivers with #AdditionalJar, how to do a SQL connection and even how to step through a ResultSet and retrieving SQL variables by column name).
 
Upvote 0
Top