ASP.NET Code:

Public Class authorVO
     Public authorID As
Integer
     Public authorName As
String
     Public authorStatus As
String
End Class

<WebMethod()> _
Public Function getAuthors(ByVal authorID As Integer) As authorVO()

Dim myConnection As SqlConnection = New _
     SqlConnection("server=YourServerName;uid=YourUserID;pwd=YourPassword;database=authors")
Dim myCommand As SqlCommand = New _
     SqlCommand("getAuthors", myConnection)

myCommand.CommandType = CommandType.StoredProcedure

Dim paramAuthorID As SqlParameter = New SqlParameter("@AuthorID", SqlDbType.Int)
paramAuthorID.Value = authorID
myCommand.Parameters.Add(paramAuthorID)

myConnection.Open()
Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter
myDataAdapter.SelectCommand = myCommand

Dim ds As DataSet = New DataSet
myDataAdapter.Fill(ds, "DataSet")
myConnection.Close()
myConnection.Dispose()

Dim i As Integer
i = 0

Dim authors As authorVO() = New authorVO(ds.Tables(0).Rows.Count - 1) {}
Dim aRow As DataRow

For Each aRow In ds.Tables(0).Rows
     authors(i) = New authorVO
     authors(i).authorID = CInt(aRow("authorID"))
     authors(i).authorName = CStr(aRow("authorName"))
     authors(i).authorStatus = CStr(aRow("authorStatus"))
     i += 1
Next

Return authors

ds.Dispose()
myDataAdapter.Dispose()

End Function

相关文章:

  • 2022-01-30
  • 2021-11-10
  • 2021-10-25
  • 2021-09-21
  • 2021-05-27
  • 2021-05-28
  • 2021-07-14
  • 2022-12-23
猜你喜欢
  • 2022-02-15
  • 2021-11-10
  • 2021-06-14
  • 2021-12-12
  • 2022-01-21
  • 2021-09-04
  • 2021-05-27
相关资源
相似解决方案