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
Rahul Lakshakar
NA
199
41.8k
Webservices with JSON response format
Sep 8 2017 6:47 AM
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.
Reply
Answers (
1
)
Determine whether Request is coming by wifi or 3g/4g in API
The underlying connection was closed: An unexpected error