Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataset in class help

Status
Not open for further replies.

shavon

Programmer
Jun 18, 2001
102
CA
Hello:

The following function is in a class. I want to return the data to the form through this function. What is the proper way to do this please?


Public Class Database
Public cn As OleDbConnection
Public cmd As OleDbCommand
Public dr As OleDbDataReader
Public da As OleDbDataAdapter
Public ds As DataSet

....more stuff

Public Function ReadData(ByVal Value As String, ByVal DsName As String) As DataSet
Dim da As New OleDbDataAdapter(Value, cn)
Return da.Fill(ds, DsName)

End Function


..........More stuff


Thank you
 
Well, if you're wanting to return a DataSet, then you need to do some work on your Fill Method.

I'm assuming that you're passing the query into the Value parameter. I don't know what you're wanting to do with the DsName parameter.

Next, your da.Fill should be on it's own line. The Fill() method is going to return an int, so you'll need an int variable to handle that. Then you can return the DataSet.

Once you return the dataset you can use the information within the datatable/datarows as you want. If the control you're wanting to put it into is a container object, you might be able to "bind" the datatable to it and not have to iterate it yourself.


im in ur stakz, overflowin ur heapz!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top