Help With Web Form Using Web Service

Results 1 to 2 of 2

Thread: Help With Web Form Using Web Service

  1. #1
    Join Date
    Dec 1969

    Default Help With Web Form Using Web Service

    I have a web service built that requires the @employeeid to be input as a parameter to return the desired data. I would like to build a web form that ties into the web service that will submit the employee id to the service and return the appropriate record back to the page. I have already generated my proxy so everything is set up right. Here&#039;s my code for the service.<BR><BR>Public Class Employee <BR> &#060;WebMethod&#062; <BR> Function GetEmployeeInfo(ByVal employeeID As Integer) As System.Data.DataSet<BR> Dim connectionString As String = "server=&#039;;; trusted_connection=true; Database=&#039;Northwind&#039;"<BR> Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionStri ng)<BR> <BR> Dim queryString As String = "SELECT [Employees].[EmployeeID], [Employees].[Title], [Employees].[FirstName], [E"& _ <BR>"mployees].[LastName] FROM [Employees] WHERE ([Employees].[EmployeeID] = @Employe"& _ <BR>"eID)"<BR> Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)<BR> <BR> sqlCommand.Parameters.Add("@EmployeeID", System.Data.SqlDbType.Int).Value = employeeID<BR> <BR> Dim dataAdapter As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter(sqlCommand)<B R> Dim dataSet As System.Data.DataSet = New System.Data.DataSet<BR> dataAdapter.Fill(dataSet)<BR> <BR> Return dataSet<BR> End Function<BR><BR>End Class<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Help With Web Form Using Web Service

    Create a simple web project with a form. In that project take a reference of this web service that you have created. To take a reference right click on the project and select "Add Web Reference". Then in the window that opens type in the address of the asmx file that you have created. click enter. This way you have taken the reference of that web service.<BR>Now instantiate an object of the service like this:<BR>dim objMyService as new ServiceName.Employee()<BR><BR>then call your service passing in the app parameter<BR>dim dsMyDataset as new dataset()<BR>dsMyDataset = objMyService.GetEmployeeInfo(1000)<BR><BR>And thats it!!!<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts