Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSON to grid 1

Status
Not open for further replies.

bestmakis

Technical User
Nov 12, 2014
22
0
0
GR
Hi

I have one asp.net page when I pass it as a parameter one sql query return as string the result.
For example if I pass a query like that in my browser:
* from Trade where code = 27000003093

The result is:

[{"Code":"27000003093","Name":"Customer Name","AlternativeName":null"fCompanyCode":"001","Modified":"\/Date(1517494429867)\/"}]

How I can put the result to a datagridview?
Any example?

Thank you
 
Assuming the result is in a string called sData:

Dim Fields() As String

Fields = sData.Split(",") 'split the string on the commas

Dim ThisField() As String

'create a datatable with appropriate columns (i.e., Code, Name, etc.)
Dim dt As DataTable
'add columns as needed

Dim dr As DataRow
dr = dt.NewRow

For Each s As String In Fields
ThisField = s.Split(":") 'split each array entry on ":", into name/value array​
dr.Item(ThisField(0)) = ThisField(1)​
Next

Or something like that. Basically, create an in-memory datatable and read the data into that.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Great example jebenson

Thank you, it is all I need....
You the best
 
Don't you think jebenson deserves a Start for the help provided?
Click on [blue]Great Post![/blue] link in his post to award a star.


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top