Using Bules thread about the MySQL connection
I've got the connection going but having trouble on the fetching of data.
Might just be me who misunderstod something.
I created this function:
If I understand it right I am creating a table called DBTableCode:function QueryDB(sQuery) DBTable = {}; cur,err = con:execute(sQuery); if not err then DBTable = cur:fetch (DBTable, "a") DBTable.nrows = cur:numrows(); end end
The query result is then passed with cur:fetch to this table as alphanumerical tables with the column name as the Table name.
If I do this:
I get a dialog that sais "Scanning" witch is the first entry in the column City in the database.Code:QueryDB("SELECT * FROM tPostnr"); Dialog.Message("test", DBTable.City, MB_OK, MB_ICONINFORMATION);
Now I thourght that I would get a table called DBTable containing 2 tables as there are 2 columns in the Database table.
So I couldt call the tables DBTable.Zipcode and DBTable.City
But I think cur:fetch only returns the first line of the query, is this correct? and in that case, does any one know how to get it to return all lines found.
if the function I set
If I call a dialog to display DBTables it tells me "1475" witch is the correct number of zipcodes in the database.Code:DBTable.nrows = cur:numrows(); --This is new for luaSQL it is not implementet in the files in bules post
So I dont know where to start.
The connection works as I can get it to show some of the content of the database and I can get it to show me the number of rows in the query I send but I can't get it to display a list of cities.
Tried using concat to concatenate the table DBTable.City that just gives an error
gives:Code:testresult = Table.Concat(DBTable.City, ";", 1, DBTable.nrows);
Argument 1 must be of type table
Any ideas?
Have anyone used the MySQL lua socket with success?
Cheers,
Jonas


