I used a littel bit of your code to do this
you can converse to your stack streamed system
PHP Code:
function DB.Query(statement)
---------------------------------------------------
---------exec
if statement == "%BEGIN" then
dblua_data.connection:BeginTrans()
return
elseif statement == "%COMMIT" then
dblua_data.connection:CommitTrans()
return
elseif statement == "%ROLLBACK" then
dblua_data.connection:RollbackTrans()
return
end
if dblua_data.recordset == nil then
dblua_data.recordset = luacom.CreateObject("ADODB.RecordSet")
elseif dblua_data.recordset.State ~= 0 then
dblua_data.recordset:Close()
end
dblua_data.recordset:Open(statement, dblua_data.connection)
-----------------------------------------------------
----------row
local row = {}
local fields = dblua_data.recordset.Fields
local i = 0
while i < fields.Count do
local field = fields:Item(i)
row[i] = field.Value
row[field.Name] = field.Value
i = i + 1
end
dblua_data.recordset:MoveNext()
--dblua_data.recordset:MoveFirst()
local t=row
-----------------------------------------------------
ret={Fields,Field={},Data={{},{}},Count}
ret.Fields=dblua_data.recordset.Fields.count
min = 1;
max = dblua_data.recordset.Fields.count
for count = min, max do
ret.Field[count]=dblua_data.recordset.Fields:Item(count-1).Name
end
dblua_data.recordset:MoveFirst()
local c=0
while not (dblua_data.recordset.EOF) do
c=c+1
ret.Data[c]={}
for i = 0, dblua_data.recordset.Fields.Count - 1 do
local Field = dblua_data.recordset.Fields:Item(i);
if Field and Field.Value then
if not (ret.Data[c][Field.Name]) then
ret.Data[c][Field.Name] = {};
ret.Data[c][i+1]= {};
end
ret.Data[c][Field.Name]=Field.Value
ret.Data[c][i+1]=Field.Value
end
end
dblua_data.recordset:MoveNext();
end
ret.Count=c
return ret
end
This returns the complete table including fields count and names, and test if recordset is working