Sample Script: TLuaDB--Create new DB object DB = TLuaDB(); --Connect to a DSN if (DB:Connect("DSN=testdsn;",TLuaDB.CLIENT_ODBC) == true) then --Insert a few rows bok = DB:Execute("insert into test (iID,sTest) values(10,'test');");
--Select all rows in table bok = DB:Execute("select * from test;");
if ( bok == true) then --Check if we got rows back if(DB:ResultAvilable() == true) then --Print how many columns this table contains iColCount = DB:ColCount(); print("Columns in this table: "..iColCount);
--Get first row while (DB:NextRow() == true) do for iCurrentCol = 1, iColCount do --GetColType and GetCol take a 1 based index iColType = DB:GetColType(iCurrentCol); sData = DB:GetCol(iCurrentCol); --Print column #, column type and data print("Col #"..iCurrentCol.." Type: ".. iColType.." Data: "..sData);
end
end
end
else
--Print error and exit SetExitStatus("Failed" .. DB:GetErrorDescription(),false);
end
else
--Print error and exit SetExitStatus("Failed to connect"..DB:GetErrorDescription(),false);
end
| |||
|
Topic 9724: Send Feedback. Download a PDF of this online book from the first topic in the table of contents. Print this topic. |