FindAllEmps 的 Visual Basic 程式碼清單
下列程式碼會建立 FindAllEmps。
Dim proxy As New server.sql_endpoint
Dim response As New Object
Dim resultXml As System.Xml.XmlElement
Dim errorMessage As server.SqlMessage
Dim outputParam As System.Int32
Dim param
Dim i As System.Int16
Dim rowCount As server.SqlRowCount
Dim outParam As server.SqlParameter
param = TextBox1.Text
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
ListBox1.Items.Add("1) Executing batch. ")
ListBox1.Items.Add("")
Dim p As server.SqlParameter()
p = Nothing
Dim s As String
s = "SELECT top 3 FirstName, LastName " + "FROM Employee " + "FOR XML AUTO"
response = proxy.sqlbatch(s, p)
' loop through response object array to find the individual items
For i = 0 To Microsoft.VisualBasic.UBound(response)
If (response(i).GetType.IsPrimitive) Then
ListBox1.Items.Add("Printing Returned Code from SP:")
ListBox1.Items.Add("The type of the element in obj array is: ")
ListBox1.Items.Add(response(i).GetType())
ListBox1.Items.Add("Return Code = ")
ListBox1.Items.Add(response(i))
End If
Select Case response(i).GetType().ToString()
Case "System.Xml.XmlElement"
ListBox1.Items.Add("Printing result of SELECT ...FOR XML")
ListBox1.Items.Add("The type of the result in obj array is: ")
ListBox1.Items.Add(response(i).ToString())
ListBox1.Items.Add("This is the result :")
resultXml = response(i)
ListBox1.Items.Add(resultXml.OuterXml)
Case "server.SqlMessage"
errorMessage = response(i)
ListBox1.Items.Add("Printing error msg, warning or other informational msg:")
ListBox1.Items.Add("The type of the corresponding obj array element is: ")
ListBox1.Items.Add(errorMessage.ToString())
ListBox1.Items.Add("This is the msg :")
ListBox1.Items.Add(errorMessage.Message)
ListBox1.Items.Add(errorMessage.Source)
Case "server.SqlRowCount"
ListBox1.Items.Add("Printing Sql Row count returned")
ListBox1.Items.Add("The type of the row count element in obj array is: ")
ListBox1.Items.Add(response(i).ToString())
ListBox1.Items.Add("Row count =")
rowCount = response(i)
ListBox1.Items.Add(rowCount.Count)
Case "server.SqlParameter"
ListBox1.Items.Add("Printing output params:")
ListBox1.Items.Add("The type of the corresponding obj array element is: ")
ListBox1.Items.Add(response(i).ToString())
ListBox1.Items.Add("Outparam name is :")
outParam = response(i)
ListBox1.Items.Add(outParam.Name)
ListBox1.Items.Add("Outparam value is :")
ListBox1.Items.Add(outParam.Value)
End Select
Next
請參閱
參考
使用 Visual Studio 2005 用戶端 (Visual Basic) 傳送 SOAP 要求