Problems Getting Parameterized values to work via Web Service

I am new to .Net and I am trying to write a Web Service to process all my database activity. The majority of examples in the MSDN Library dont use a Web Service so I am stumbling on getting parameterized data back and forth.

In my Web Service (HampelService), I have a SQLDataAdapter TTParmDA connected to my SQL database, and the configuration looks like this:

SELECT TankTypeID, Description
FROM StorageTankType
WHERE (TankTypeID = @TankTypeID)

I Generated a DataSet dsTTparm and was able to preview the data when I entered the Parm Value in the data Adapter Preview Screen. Note on this screen it indicated that the type of TankTypeID was ansiString.

When I opened the collection of Parameters under the SelectCommand/Parameter in the Properties of the DataAdapter, It said that there was one parameter and it was defined like this.

Direction: Input
Size: 10
SourceColumn: TankTypeID
SQLDbType: VarChar
Parameter Name: @TankTypeID

So Far I think Everything is ok.

The following is the Code on the Windows form trying to get a parameterized value across to my web service. Basically I am sending it a string of 1.

Dim tmp As String
tmp = txtTest.Text I set it to 1 in a textbox

Dim ws As New Hampel.localhost.HampelService
ws.Credentials = System.Net.CredentialCache.DefaultCredentials


The Parameter arrives to the Web Service as 1 in the vTankTypeId , but I think I have a problem with the Select Command setup since it is not working. I have tried defining The parameter coming across as string, System.Object, etc.

Web Service Code
Public Function GetTankType(ByVal vTankTypeId As String) As dsTTparm
Dim Tanktypes As dsTTparm
TTParmDA.SelectCommand.Parameters.Add("@TankTypeID", _
System.Data.SqlDbType.VarChar, 10).Value = vTankTypeId

Return Tanktypes

End Function
It errors out in this piece of code in the Web Reference of the Application code.


Public Function GetTankType(ByVal vTankTypeId As Object) As daTTParm
Dim results() As Object = Me.Invoke("GetTankType", New Object() vTankTypeId})
Return CType(results(0), daTTParm)
End Function

Microsoft Development Environment Error Message is as follows:

An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in

Additional information: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: dataSet
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at HampelWebService.HampelService.GetTankType(String vTankTypeId) in c:inetpubwwwrootHampelWebServiceHampelService.asmx.vb:line 747
--- End of inner exception stack trace ---

Hope someone can Help Thanks

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!