You have to loop through the rows to format the data to JSON string. Let's consider an example that your datatable contains two columns: - FirstName - LastName then, the code might be: Note: - Am not giving the exact code
protected function ConvertDataTableToJSON(byval dt as DataTable)
Dim strJSON as string
strJSON = "{"
for each row as DataRow in dt.Rows
strJSON = strJSON + "'firstName':" + "'" + row("FirstName") + "',"
strJSON = strJSON + "'lastName':" + "'" + row("LastName") + "',"
end for
strJSON = strJSON + "}"
return strJSON
end function
Hope this will be useful. Please refer the following link for JSON format: http://en.wikipedia.org/wiki/JSON[^] Thanks, Rajdev KR