'Declare a pointer to the result table If res = 0 Then 'Get the pointer to the result table restab = mysql_store_result( db ) If restab > 0 Then Dim As Integer nrow 'How many rows are in the result table? nrow = mysql_num_rows( restab ) Print nrow If nrow > 0 Then Dim As Integer i, j, ncol Dim As mysql_row row 'How many columns are in the result table? ncol = mysql_num_fields( restab ) Print ncol

'Read the result table. For i = 0 To nrow - 1 'Get the next row of the result table row = mysql_fetch_row( restab ) Print i, 'Print all columns of the current row to the screen. For j = 0 To ncol - 1 Dim s As String: s = *row[j] Print s; " - ";

Just a small suggestion, grindstone. Even for trivial examples, never append user-supplied variables to a query string (internal program variables are usually fine since you the programmer can guarantee they will always contain valid data). Never ever do it. Even if you think it won't matter. Your query string is a prime example of an SQL injection bug. All someone needs to do is walk up to the POS machine and enter a password like this:

or worse. Any query the user wants to run can be placed in the password. Of course he might not get a good way of reading the data out, but could do all sorts of mischief. You might think I'm being pedantic, but good habits start early! Instead of appending unfiltered user data to a query, you need to use parameterized queries. It adds some steps, but it's really important if you're querying based on *any* user-supplied input. It's a three-step process. First you create the query with placeholders for the data, then you bind your FB variables to the query, then you execute it. I'm not sure why mysql bi file you're using, but I hope it exposes mysql_stmt_prepare() and friends:https://dev.mysql.com/doc/refman/8.0/en ... rview.html

I beg your pardon, but you're railing against the wrong one :-) . Everything but the lines framed by "'########" is originally the code Gablea posted here. I only re-posted the whole snippet to make clear where to place the additional lines.

Apart from that I agree with you. The common use of global variables is surely an aftereffect of the program's DOS origin, but it makes the co-developing not easier.

So it's purport that the query delivers either one row (if user ID and password match) or none (otherwise).

The only mistake that I can find in your snippet is that you close the API access (mysql_close(db)) without first releasing the memory (mysql_free_result(restab)). If the snippet is running in a loop this probably causes a memory leak that ends in a crash.

Gablea wrote:Is it possible to do in memory table with MySQL? (Local to the machine)

The idea behind a database server is that you have all the data on 1 machine only and the clients with very limited data, only the data needed a a specific time. Every request or change is done via the database server. If the client catches fire, no problem. If two clients want to update the same product amount, (nearly) no problem.

I understand that but my VB.net version it uses a in memory table to control the receipt data as well as any promotions and i have almost all the code created for all the offers etc so I would like if possible to replicate the function with FreeBASIC