Filling a dataset from a function in a class

garyheffern

New member
Joined
May 25, 2005
Messages
1
Im having problems filling a dataset that I created using the XML Designer and then dragging a dataset object from the toolbox on to the form. Heres the code:

Heres the call from my form:
Dim dsOrderItems As dsOrderItems
dsOrderItems = SOESdb.GetOrderItems(m_intOrderNumber)

Heres the function in the DB class:

Public Shared Function GetOrderItems(ByVal OrderNumber As Integer)

Dim dsOrderItems As New dsOrderItems

Dim cmdOrderItems As New SqlCommand

Dim daOrderItems As New SqlDataAdapter

cmdOrderItems.Connection = SOESConnection.GetSOESConnection

cmdOrderItems.CommandText = "spGetOrderItems"

cmdOrderItems.CommandType = StoredProcedure

cmdOrderItems.Parameters.Add(New SqlParameter("@OrderID", SqlDbType.Int, 4)).Value = OrderNumber

daOrderItems.SelectCommand = cmdOrderItems

daOrderItems.Fill(dsOrderItems, "spGetOrderItems")

Return dsOrderItems

End Function



Can you please tell me what change is needed to the function or call. Thank you so much! Ive been working on this for two days and Im starting to panic!!!

Gary
 
One thing - dont name your object instances the same as the class name. Ex:

Dim dsOrderItems As New dsOrderItems


change it to something like:

Dim ds As New dsOrderItems
 
Back
Top