Question Query help needed for a web sevice

technohead

New member
Joined
Jan 18, 2010
Messages
1
Programming Experience
Beginner
Hi, I am relativly new to programming and am having some difficulty with a problem. I am trying to display results for a query using a web service. So far I have been able to display the results for a full table. But I want to be able to display the results for a specific parameter, ItemID

So far I have the following code which displays the results for the full table.

VB.NET:
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient


' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class ViewStockUnAuth
    Inherits System.Web.Services.WebService

    <WebMethod()> Public Function GetStockPriceUnAuth() As DataSet
        Dim strSelect As String
        Dim conn As SqlConnection
        Dim dadStock As SqlDataAdapter
        Dim dstStock As DataSet
        Dim connString As String

        connString = "removed"

        strSelect = "SELECT * FROM tblItem"

        conn = New SqlConnection(connString)
        dadStock = New SqlDataAdapter(strSelect, conn)
        dstStock = New DataSet
        dadStock.Fill(dstStock, "tblItem")

        Return dstStock


    End Function

End Class


I want to display the resluts for a specific item using its unique identifier. Item ID. So there is a text box visible in the web service for the item ID paramter I wish to use. I have tried to use the 'where' function in the query but, i dont think this is the correct soloution. As it won't add the input box to my web service.

Any help would be gratefully accepted. Many thanks
 
To add the textbox in operation sample page your webmethod needs a parameter, ex:
VB.NET:
Public Sub Method(ByVal key As Integer)
 
Back
Top