Forum Moderators: open
Web Server should get data from database and send it to a client. I never did it before and I am stuck. On-line help doesn't make it easier.
I created a Web Service with methods such as
<WebMethod> Public Function GetData(ByVal sSQL As String) As DataSet
Dim oCmd As SqlCommand = New SqlCommand(sSQL, cn)
Dim da As SqlDataAdapter = New SqlDataAdapter(oCmd)
Dim ds As New DataSet()
Try
da.Fill(ds)
Return ds
Catch e As SqlException
MsgBox(e.Message)
cn.Close()
End Try
End Function
My questions:
1. (MOST IMPORTANT) The problem I am having with adding webreference right now is that while I use "localhost" reference is added, but when I copy files to another webserver and use that server's name, instead of reference I get Open/Save Target/Cancel dialog box. It sees the file but as something to download not as reference.
Why is that?
2. I tried Datareaders I got an error message saying that DataReader cannot be serialized so I cannot use them. Is there a way around it?
3. Does this webreference mean that in the event my server program will be moved to another server I will need to change client program and recompile it? Is there a way to specify server name in INI or registry?
4. I keep reading about SOAP in connection with all this. Do I need to do anything with it?
Please, help
If you just want to test to see what the return XML looks like, try using view-source:http://url in the command line of IE or netscape.
2. A DataReader is an object that gets the data. It isn't the data itself. So you can't pass the DataReader iself, but must pass the data that the DataReader gets. This is done by filling in a DataSet and passing the DataSet. So you can use a DataReader instead of a DataAdapter in your example, but you still need to fill the DataSet.
3. You can certainly store the info somewhere, such as a constant declaration in the global.asax. Realize though, that on an ASP.NET application, any time that you change a page, it will automatically recompile the web site on the next request to a page. So you don't need to explicitly recompile the web site to get the change to propagate.
4. SOAP is going on behind the scenes. If you use .NET on both sides of the transaction, you don't really have to understand how it works.
3. Web reference to CLIENT is added at design time. If my server address changes how can I change the reference in client (local workstation) without recompiling it?