Web Service for SQL Query

bortiquai

Member
Joined
Jul 5, 2007
Messages
17
Programming Experience
Beginner
I think need to create a Web Service to execute sql query statements from a remote client. I'm not really sure where to begin on this. I only need simple select statements, but from remote users out on the internet.

I'm doing this in VB. the Client App is already written, but connects to a SQL Server on the local network. I want to do the same thing, but now the users will be outside the local internet.

Could someone point in the direction of where to start, or examples or documentation for a simple web service like this.

Thanks
 
First of all do you have a web server? If so, do you have a website running? If so, do you have access to the web site through IIS? If so you should create a virtual directory and create a web service project using VB.NET into this directory. Then you must create web methods that will run your queries. Returning some type of string or xml data. Web methods are declared like so

VB.NET:
<WebMethod()> Public Function Function_Name() as String

Because Web Services are supposed to be cross-platform keep in mind that you can only pass primitive data types for the most part. I am fairly new to Web Services so I am not sure about all of the limitations of this, but I do know I created a web service the other day and could not pass a dataset through a web method and solved this by a passing a string containing the XML.

Then, the next step is optional, but I would prefer to create a WinForms application that contains a web reference pointing the url of the web service (ending in .asmx) and call those web methods in some sort of application so that you can provide better functionality for the end users naturally this is optional but you might want to let your users view the selected data with a datagrid or something like that and this was how you do it.

I understand that you may need more information. But try it out. Create a Virtual Directory on your web site in IIS. Try your best to specify the correct settings for your application. Create a web service project in the path of the virtual directory. Then create a windows application with a web reference pointing to the location of the web service on the web server. You should then be able to create an application that can access your database from anywhere in the world (assuming this url is public and not local to your network). But give it a try and let me know how it went.
 
Thank you for the reply

So i was able to create the project for the webservice on my web server, and that seems to be working fine.

How do i call this from the remote application? The remote application is a VB.net project.
 
Keep me posted...Let me know how it went...I've only made three web services in my life. But once I learned what they actually did, I was mesmorized with their capability, been reading up on them ever since.
 
Because Web Services are supposed to be cross-platform keep in mind that you can only pass primitive data types for the most part. I am fairly new to Web Services so I am not sure about all of the limitations of this, but I do know I created a web service the other day and could not pass a dataset through a web method and solved this by a passing a string containing the XML.
refer http://msdn2.microsoft.com/en-us/library/3003scdt.aspx, you can pass primitives, enums, DataSet, XmlNode and arrays of these. You can also return custom types (classes) with members of mentioned types, the consumer will look to the service definition when using such return.
 
Back
Top