TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sanjay gautam
NA
90
14.3k
convert table to json
Oct 18 2019 12:49 AM
static
public
string
table2Json(DataSet ds,
int
table_no)
{
try
{
// Given a Dataset & Table NO , function returns a 2 dim JSON Array of values in that table
int
rcnt = ds.Tables[table_no].Rows.Count;
// Row Count
int
ccnt = ds.Tables[table_no].Columns.Count;
// Col Count
object
[][] tb =
new
object
[rcnt][];
int
r = 0;
foreach
(DataRow dr
in
ds.Tables[table_no].Rows)
{
tb[r] =
new
object
[ccnt];
for
(
int
col = 0; col < ccnt; col++)
{
tb[r][col] = dr[col];
if
((tb[r][col]).Equals(System.DBNull.Value))
tb[r][col] =
""
;
}
r++;
}
var table= JsonConvert.SerializeObject(tb);
return
table;
}
I have some code for convert table to json string i want to remove for loo from these code how does it is possible
Reply
Answers (
4
)
Can I convert EventArgs type to PaintEventArgs type ?
Console application crashing