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 2004

Tip: Looking for answers? Try searching our database.

Returned Dataset Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David York - 14 Sep 2004 13:08 GMT
I have created a web service that access a database and retrieves record
then returns them as a dataset. I am having a problem coding a client
application to use the dataset. Here is the relevent code:
Web Service Code:

Public Function Query(ByVal computername As String) As DataSet
   Dim conStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Server.MapPath("inv.mdb")
   Dim sqlStr As String
   sqlStr = "SELECT * FROM inv WHERE Decal = '" & computername & "';"
   Dim myConnection As New OleDbConnection(conStr)
   Dim myCommand As New OleDbCommand(sqlStr, myConnection)
   myConnection.Open()
   Dim myDataAdapter As New OleDbDataAdapter
   myDataAdapter.SelectCommand = myCommand
   Dim myDataSet As New DataSet
   myDataAdapter.Fill(myDataSet)
   myConnection.Close()
   Return myDataSet
End Function

Client Code:

Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
   Dim computername As String
   computername = TextBox1.Text
   Dim ws As New invweb.Inventory_Database_Query
   Dim querydata As DataSet
   querydata.Merge(ws.Query(computername))
End Sub

This generates a
System.NullReferenceException
it says:
Object reference not set to an instance of an object.
on
querydata.Merge(ws.Query(computername))

any suggestion on how to get this to work.

Thanks in advance

David York
John Wadie - 14 Sep 2004 13:17 GMT
You should instantiate the dataset before calling the Merge method, replace
this line

Dim querydata As DataSet

With

Dim querydata As New DataSet

Cheers,
John Wadie
Steve Maine - 14 Sep 2004 23:09 GMT
I'm not a VB.NET guy, but it looks like you're only declaring querydata, not instantiating it. Try this at your client:
 >Dim querydata As New DataSet

-steve
http://hyperthink.net/blog

> I have created a web service that access a database and retrieves
> record
[quoted text clipped - 38 lines]
>
> David York

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.