This question is locked. New answers and comments are not allowed.
I have run into a problem with using the GetSqlQuery() in IObjectScopeProvider.
I have the following code that causes this error:
Query failed: System.NullReferenceException: Object reference not set to an instance of an object.
at OpenAccessRuntime.Data.VariableLengthStringConverter.Write(DataHolder& data)
at OpenAccessRuntime.Relational.RelationalQueryResult.SetParameters(RelationalCompiledQuery rcq, PreparedStatement stat, Object[] values)
Now when I change the first two lines to below. the code executes and runs fine. I assume the SELECT IN clause is what is causing the error, seeing as that is the only change. Is there a way to accomplish this without putting all my "complex" sql code into stored procedures?
thanks
I have the following code that causes this error:
Query failed: System.NullReferenceException: Object reference not set to an instance of an object.
at OpenAccessRuntime.Data.VariableLengthStringConverter.Write(DataHolder& data)
at OpenAccessRuntime.Relational.RelationalQueryResult.SetParameters(RelationalCompiledQuery rcq, PreparedStatement stat, Object[] values)
IQuery q1 = sc.GetSqlQuery(@
"SELECT PopulationID, LocationName, Direction, Distance FROM populations WHERE populationid IN (SELECT populationid FROM populationswrittenreports WHERE writtenReportID = ?)"
,
typeof
(Population),
"VARCHAR writtenReportID"
);
IQueryResult res = q1.Execute(
new
object
[] { reportID });
try
{
int
count = res.Count;
return
DataDriver.Utilities.ToList<Population>(res.ToList());
}
catch
{
return
new
List<Population>();
}
Now when I change the first two lines to below. the code executes and runs fine. I assume the SELECT IN clause is what is causing the error, seeing as that is the only change. Is there a way to accomplish this without putting all my "complex" sql code into stored procedures?
IQuery q1 = sc.GetSqlQuery(@
"SELECT PopulationID, LocationName, Direction, Distance FROM populations "
,
typeof
(Population),
null
);
IQueryResult res = q1.Execute();
thanks