Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Webservices with JSON response format
Rahul Lakshakar
Sep 8 2017 6:47 AM
149
Reply
Hello,
I am creating web services in my asp.net project and getting result in the format of JSON. First webmethod is working is fine but in second one i am getting no value in JSON array.
Can any one suggest me something?
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)> _
Public Function GetStudentJSON(sname As String) As String
Dim sqlStr As String = "Select * from vw_Student where SName like '%" & sname & "%' "
Dim myReader As SqlDataReader = ExecuteQuery_ExecuteReader(sqlStr)
Dim student As New List(Of Student)()
While myReader.Read
student.Add(New Student() With { _
.SID = myReader("SID"), _
.RegNo = myReader("RegNo"), _
.SName = myReader("SName")})
End While
myReader.Close()
Return New JavaScriptSerializer().Serialize(student)
End Function
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)> _
Public Function GetParentJSON(SID As Integer) As String
Dim sqlStr As String = "Select * from ParentLogins where SID = '" & SID & "' "
Dim myReader As SqlDataReader = ExecuteQuery_ExecuteReader(sqlStr)
Dim student As New List(Of Student)()
While myReader.Read
student.Add(New Student() With { _
.SID = myReader("SID"), _
.RegNo = myReader("RegNo"), _
.SName = myReader("SName")})
End While
myReader.Close()
Return New JavaScriptSerializer().Serialize(student)
i am using a student class in this.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Determine whether Request is coming by wifi or 3g/4g in API
The underlying connection was closed: An unexpected error