Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a Parameter to WebMethod from a VB.NET client

Status
Not open for further replies.

markk609

Programmer
Feb 19, 2005
11
US
I have created a WebMethod (named GetNew()) which returns a dataset based on a parameterized query. This WebMethod is successfully exposed and can be successfully invoked through my IE browser, prompting me for the query's parameter value before returning the dataset. All I want to do is be able to pass in the parameter value when I call this method programatically from my VB.NET Windows application code. Can I somehow place a parameter into the ws.GetNew() call in my VB.NET code? Nothing I have tried can be built in VisualStudio.NET. I have a feeling that I am missing something that must be very fundamental. Any guidance will be deeply appreciated.
 
Could you post relevant code?

__________________________________________
Try forum1391 for lively discussions
 
Have you tried ws.GetNew(param)?

__________________________________________
Try forum1391 for lively discussions
 
Thank you for your reply. Yes, I certainly have tried ws.GetNew(param). For some reason, entering a parameter in the ws.GetNew() call is immediately flagged as an error and is accompanied by the following build error message:

"Class 'WindowsApplicationTPC2.localhost2.dsNew' cannot be indexed because it has no default property."

The WebMethod code is as follows:

<WebMethod()> Public Function GetNew(ByVal parm1 As String) As dsNew
Dim assigns As New dsNew
SqlDataAdapter1.SelectCommand.Parameters(0).Value = parm1
SqlDataAdapter1.Fill(assigns)
Return assigns
End Function

The event script from which this WebMethod is being called is as follows:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ws As New WindowsApplicationTPC2.localhost2.ServiceNew2
ws.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim param As String
param = "JK"
AssignsData.Merge(ws.GetNew(param))
End Sub

Anyway, thank you in advance for whatever light you can cast on this.
 
What do you want to accomplish here (highlighted):

<WebMethod()> Public Function GetNew(ByVal parm1 As String) As dsNew
Dim assigns As New dsNew




__________________________________________
Try forum1391 for lively discussions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top