- 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;
- }
Loading
Mageshwaran RPosted Nov 25, 2019, 9:56 AM
Amit MohantyPosted Oct 18, 2019, 1:23 AM
Sanjay gautamPosted Oct 18, 2019, 1:19 AM
Amit MohantyPosted Oct 18, 2019, 1:14 AM