473,326 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Returned Dataset Question

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
Nov 21 '05 #1
2 1594
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
Nov 21 '05 #2
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
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


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I had some code that worked fine for several weeks, and then yesterday it stopped working. I'm not sure what I did. Nor can I make out why it isn't working. I'm running a query that should return 3...
6
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
2
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
8
by: Programatix | last post by:
Hi, I'm working on a project which includes XML WebServices and Windows Form application. The Windows Form application will call the XML WebServices to retrieve data from database. The data...
1
by: Evgeny.Br | last post by:
Hi All, I use .NET 2.0. I experience huge performance problem retrieving dataset from web service. The dataset volume returned from WS is about 5-7 megabyte, it's take too long.
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.