I have a odb file with 2 records in it with the value of 2000000 in PON and 1 in ID that I’m trying to read with a macro in Calc 5.2.5.1. No matter what advice I follow from Google all I get is:
BASIC runtime error.
An exception occurred
Type: com.sun.star.sdbc.SQLException
Message: No data is available.
I get the correct result when I use the query in Base:
SELECT PON FROM Data WHERE ID = 1;
PON is updated if I run the macro in Calc
UPDATE ““Data”” SET PON = 268680 WHERE ID = 1;
I know I’m talking to the odb file.
What do I need to change to make this macro work?
Context = CreateUnoService("com.sun.star.sdb.DatabaseContext")
Db = Context.getByName(DATABASE_NAME)
Conn = Db.getConnection("","")
strSQL = "SELECT PON FROM ""Data"" WHERE ID = 1;"
Stmt = Conn.createStatement()
Result = Stmt.executeQuery(strSQL)
If Not IsNull(Result) Then
MsgBox Result.getLong(1)
End If
My goal is to read the record, increment it by one and save it.
Thanks and I hope I’ve included everything you need.
Bob