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