Listato di codice Visual Basic per ExecSP
Il codice seguente consente di creare ExecSP.
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
' for DataSet test
Dim resultDS As System.Data.DataSet
' end of DataSet test
ListBox1.Items.Add("1) Executing SP. Results returned as DataSet objects. Result is ")
ListBox1.Items.Add("")
param = TextBox1.Text
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
response = proxy.GetCustomerInfo(param, outputParam)
' 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 "System.Data.DataSet"
ListBox1.Items.Add("Printing result of SELECT ...without 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)
resultDS = response(i)
'ListBox1.Items.Add(resultXml.OuterXml)
ListBox1.Items.Add(resultDS.GetXml())
' ----------
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
Vedere anche
Riferimento
Invio di richieste SOAP utilizzando il client di Visual Studio 2005 (Visual Basic)