Question Data Retrieval

kclark

New member
Joined
Nov 10, 2012
Messages
1
Programming Experience
1-3
I'm working on a really simple web service and hoping to get some help. I took the stock web service from Visual Studio, and started modifying it with very limited knowledge of ODP.NET. Effectively, what I'm trying to do is bring back a set of results from a SQL Query that has a variable in it that I pass to the service. WR_Premise is the variable that I'd like to incorporate, after I get my query working correctly. I call my function using the WCF Test client, but am getting a InvalidOperationException when I try to run the following code.

`Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData
Dim wrpremise As Integer
Dim state As String
Dim queryString As String = _ "select MV_OUTAGE_DURATION.CAUSE_DESC, MV_OUTAGE_DURATION.DEV_NAME, MV_OUTAGE_DURATION.DEV_TYPE_NAME, MV_OUTAGE_DURATION.EVENTNUM, MV_OUTAGE_DURATION.OUT_MINUTES, MV_OUTAGE_DURATION.OFF_DTS , MV_OUTAGE_DURATION.RESTORE_DTS , MV_OUTAGE_DURATION.SYS_RESP_TYPE from MV_we_outage_premise, MV_OUTAGE_DURATION where mv_we_outage_premise.evntnum = MV_OUTAGE_DURATION.eventnum and mv_we_outage_premise.we_premise = '995184' order by(MV_OUTAGE_DURATION.RESTORE_DTS)"
Dim command As New OracleCommand(queryString) value = wrpremise
Dim oradb As String = "Data Source=****;User Id=******;Password=***********;"
Dim conn As New OracleConnection(oradb)
conn.Open()
state = conn.State.ToString()
command.ExecuteNonQuery()
MsgBox(state)
conn.Close()
state = conn.State.ToString()
MsgBox(state)
Return String.Format("You entered: {0}", value)End Function`
I can get the service to work and return the states when I take the command.ExecuteNonQuery() out of the service, but that doesn't help me out much... Also, anyone know an easy way to output the results to XML?
 
First things first, please don't post your code snippets using
tags. They are for quotes and do little to help the readability of code snippets. Please us the appropriate
VB.NET:
 or [xcode=vb] tags, both of which can be added using a button on the advanced editor or typed in manually.  Just copy and paste your code as plain text.

Secondly, you say that you get an exception but did you examine the exception to see what information it provides?  That's the first thing you should do.  There's an error message and a call stack that are the most immediate sources of information but more besides.  If you'd done that then, from what I can see, you'd have been told that you handn't set the Connection property of your command.  It should be fairly clear what you need to do to fix that.
 
Back
Top