Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / January 2007

Tip: Looking for answers? Try searching our database.

how to pass a value in this webservice?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 24 Dec 2006 16:17 GMT
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
....
Bob - 25 Dec 2006 15:42 GMT
I found it.
pcinfo(ByVal pcnr As String)

> Hi,
>
[quoted text clipped - 29 lines]
>    End Function
> ....
RYoung - 13 Jan 2007 21:03 GMT
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

>I found it.
> pcinfo(ByVal pcnr As String)
[quoted text clipped - 32 lines]
>>    End Function
>> ....

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.