SQLDataReader issue

Jul 21 2020 9:23 AM

the below Query gets executed in my SQL DB

WITH XMLNAMESPACES(DEFAULT 'http://schemas.datacontract.org/2004/07/Shared.ViewModels.Warehouse')

select
t.bondId,
t.bondName,
x.inf.value('(ExpDate)[1]', 'datetime2') as ExpDate
from MyTable as t
cross apply
(
select cast(t.BondXMLinfo as xml) as BondXMLinfo
) as ca
cross apply ca.BondXMLinfo.nodes('/CompanyInfo') as x(inf)


but, When I try to execute the same SQL Query using SqlDataReader from C#.NET, i get empty output in DataTable.


using (SqlCommand myCommand = new SqlCommand(<MYSQLQuery>, connection, transaction))
{
using (SqlDataReader myReader = myCommand.ExecuteReader())
{
DataTable myTable = new DataTable();
myTable.Load(myReader);


Answers (1)