how to pass a value in this webservice?

B

Bob

Hi,

I made a webservice for fetching data from a database. It works good.
Now i would like to add a parameter to the sql command. The user should
enter a value (pcnr) before the
data is fetched. I tried to add a texbox but it doesn't work.
How can i do that?
Thanks
Bob

My code:
......
<WebMethod()> _
Public Function pcinfo() As DataSet
Dim oConnection As OleDbConnection
Dim pcnr As Integer
Dim d As OleDbDataAdapter
oConnection = New OleDbConnection()
Dim sql As String
Dim ds As New DataSet

Dim tb As New TextBox
pcnr= Convert.ToInt16(tb.Text)

sql = "SELECT * from pc where pcnr=" & pcnr & ";"
Dim sConnectionString As String
sConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source
= c:\mytable.mdb"
d = New OleDbDataAdapter(sql, sConnectionString)
d.Fill(ds)
Return ds
End Function
.....
 
R

RYoung

Glad you found it. Keep in mind that the Web service has no clue as to what
client is using it. I say that because from your question I gather the
client is a .NET app, by the use of TextBox. A service has no visual
interface, unless the service host is a GUI application, and therefore
shouldn't be concerned with UI controls.

Your service would want to stick with dealing with the primitives types
(int, string, double, bool, etc), or with serializable complex types built
from primitive types.

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top