Beginner Web Service error: Object reference not setHello,

D

Derek Correia

Hello,

I'm just getting started with web services. I've written one that takes
an integer and searches an Oracle database for that customer ID. I want
it to return all records with that customer ID. Below is the code of
the ASMX page:

---------------

<%@ WebService Language="VB" Class="WebCenter" %>
Imports System.Web.Services
Imports System.Data
Imports System.Data.OracleClient
Imports System.Configuration


Public Class WebCenter
Private Function GetDataSet(strSQL as String) as DataSet

Dim oraConn As OracleConnection = New OracleConnection("Data
Source=ORASRV;Integrated
Security=no;user=WEBSERVICE;password=WEBSERVICE;")
Dim oraCMD As OracleCommand = New OracleCommand(strSQL , oraConn)

oraConn.Open()

Dim myDataAdapter as OracleDataAdapter
myDataAdapter.SelectCommand = oraCMD

Dim myDataSet as New DataSet()
myDataAdapter.Fill(myDataSet)
oraConn.Close()

Return myDataSet
End Function



<WebMethod()> Public Function FindMember(memid as Integer) as
DataSet
dim strSQL as string
strSQL = "SELECT * FROM DW_USERS where SUBSCRIBER_ID=" & memid
Return GetDataSet(strSQL)
End Function
End Class


------------

When testing the above code using HTTP get from the localhost, I get
the following error:

System.NullReferenceException: Object reference not set to an instance
of an object.
at WebCenter.GetDataSet(String strSQL)
at WebCenter.FindMember(Int32 memid)

Is there something I am doing wrong? This is on a Windows 2k server
with .Net framework 1.1 installed. Thank you.

-Derek
 
H

Hadi Hariri

Have you tried tracing? You're referencing an object that you have not
created or has been freed. Put a breakpoint and you'll hit it instantly.
 
D

Derek Correia

Thank you Hadi. I found the issue, and it was that I was doing string
operations on a string that was not properly defined. The breakpoint
threw it right in my face. Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top