DBReader

public class DBReader

 Methods

bool IsClosed()

Indicates if the reader has been closed

bool Read()

Read the next row from the database

void Close()

Close the reader

void Dispose()

Disposes the reader. Its important in non-sandboxed environments to dispose the reader to avoid memory leaks

object GetValue(int index)

Get the value of the column of the current row by index

Example

This example sets and updates information about a person

s = Database.GetSchema("Datastorage")
hasData = False
with s.Select("select Id, Name, Age from Person") as reader:
   while reader.Read():
      hasData = True
      ProcessInstance.Warn("DBData:"+str(reader.GetValue(1)))
      mId = reader.GetValue(0)
      mAge = reader.GetValue(2)
if hasData:
   s.Execute("UPDATE Person SET Age=%d WHERE ID=%d" % (mAge + 1, mId))
else:
   s.Execute("INSERT INTO Person (Name,Age) VALUES ('Frank',45)")
s.Close()