Skip to Content
0
Dec 07, 2022 at 06:52 PM

Multi result using HanaCommand in .NET

213 Views

Hi all, I want to get multiple select result while executing HanaCommand, but HANA DB throws a error: Sap.Data.Hana.HanaException (0x80004005): sql syntax error: incorrect syntax near "SELECT": line 2 col 1 (at pos 28)

when I'm doing like in the code below. Is it possible to put in there multiple queries to read many results?

using (var con = new HanaConnection(conString))
{
	con.Open();

	using var cmd = new HanaCommand(@"SELECT COUNT(*) FROM ITEM1;SELECT ID FROM ITEM2;", con);
	using var reader = cmd.ExecuteReader();
		
	while (reader.Read())
	{
		// do stuff
	}

	reader.NextResult();

	while (reader.Read())
	{
		// do stuff...
	}
}