Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / September 2005

Tip: Looking for answers? Try searching our database.

Beginner Web Service error: Object reference not setHello,

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Derek  Correia - 08 Sep 2005 22:37 GMT
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
Hadi Hariri - 09 Sep 2005 17:47 GMT
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.
Derek  Correia - 09 Sep 2005 19:08 GMT
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!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.