Writing a Visual Studio 2005 Client Application

This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

By using the Web reference mechanism in Visual Studio 2005, you can call stored procedures, user-defined functions, or the sqlbatch method for ad hoc queries, just as you would call any other method on an object in your application.

Sending SOAP Requests

When you use a Visual Studio 2005 client to send SOAP requests to an instance of SQL Server, you must first add a Web reference to the project and specify the URL of the WSDL document, for example: https://server/sql2?wsdl, where https://server/sql2 is the URL specified for the endpoint that was defined by using CREATE ENDPOINT.

In response, Visual Studio creates a Web Service proxy class and adds it to your project. This proxy class exposes the methods of the Web service defined by the specified WSDL document. By using this proxy class, you can invoke any one of the methods exposed by the endpoint. If the endpoint allows for ad hoc query requests, the WSDL document includes the sqlbatch method that you can use to specify ad hoc SQL queries. Internally, a SOAP request is sent to the instance of SQL Server. It executes the method and returns the result (the SOAP response) to the client.

Processing Response

The result of an operation can be returned as an object array. The following table lists and describes the types that the array elements can be.

Types

Description

XMLElement( System.Xml.XmlElement)

Holds the results of a SELECT... FOR XML query.

DataSet (System.Data.DataSet)

Holds the results of a SELECT query.

SqlMessage (a custom type defined by the WSDL)

Holds error, warning, and other informational messages that are returned.

SqlRowCount (a custom type defined by the WSDL)

Holds the row count (number of rows affected by the query) that is returned by the instance of SQL Server.

SqlParameter ( a custom type defined by the WSDL)

Holds the collection of output parameters returned by the instance of SQL Server.

Note

When a stored procedure is executed, the return code value is returned as an integer type array element.

Because object array elements can be of any one of the previous types, you must first determine the type of an object, and then process it accordingly. For working samples, see Sending SOAP Requests by Using Visual Studio 2005 Client (C#) and Sending SOAP Requests by Using Visual Studio 2005 Client (Visual Basic).