Creating my first Web Service in VB.net / SQL Server Database / Creating + Passing back an Array
Posted on 2005-03-15
Okay I am a bit lost in here...
First off do I have to be creating my web serivce on the server where the web service is going to be hosted ..ie the server.
Next I have to connect to Sql Server via VB.Net.
I have to read and write to this database based on what is coming in from the client side.
Here is what is done now on the client side....
A row of buttons are created and the user will save a color that they will select which will be the background color of the button...these colors will be saved in the database on the web service and when the user logs on to the client...it has to fire at the web service and the web service is supposed to return the colors from the db for these buttons so on the load the colors are displayed.
Right now I have SQL Server with the database name... Sands and the table name is ... rec_type where the colors are stored for each button ...for eg: the colors for button1 ( eg ID = 1) is bg_color1 = 255, bg_color2= 236, bg_color3=241).....so basically for EACH button I need to return back to the client 3 color parameters
This what I have done so far for publishing the web service...i have based this on what I can gather on the web...but I am not sure about the database connection (SQL Server...executing query) and how I should be returning back the parameters back to client...right now I have a boolean ...I know this is wrong..I am thinking an array is going to have to go back to the client.
Public Class Service1
Dim oSQLConn As SqlConnection = New SqlConnection
<WebMethod(Description:="Method to retrieve the user preferences.")> _
Public Function RetrieveFeatures(ByVal ID As Integer) As Boolean
Dim CmdCat As SqlCommand = oSQLConn.CreateCommand()
CmdCat.CommandText = "Select button_color_1,button_color_2,button_color_3 FROM Rec_Types Where ID = '" & ID & "'"
oSQLConn.ConnectionString = "Data Source =(local):Initial Catalog=Sands:Intergrated Security=SSPI"
Catch exception As SqlException
Any insight or help would be greatly appreciated.