First of all, we have to fetch the records from the database (MS Sqlserver) into the C# DataTable, or we can add dynamic rows to our DataTable. So our code looks like as written below.
//*
)
{
;
;
;
;
;
;
;
;
;
;
;
;
}
 
方法一:Fetch each data (value), and append to our jsonString StringBuilder. This is how our code looks like
 
)
{
;
)
{
;
)
{
;
)
{
)
{
)
;
}
)
{
)
;
}
}
)
{
;
}
else
{
;
}
}
;
}
;
}
//*
 

方法 2: Convert DataTable to JSON using JavaScriptSerializer:

)
{
;
;
;
)
{
;
)
{
;
}
;
}
;
}
 

方法3(推荐): Convert DataTable to JSON using Json.Net DLL (Newtonsoft):

)
{
;
;
;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2022-02-19
  • 2022-12-23
  • 2021-09-08
  • 2021-09-14
猜你喜欢
  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2018-03-03
相关资源
相似解决方案