Dataset fill through a class

I have a program I wrote a little while back and in it I fill various datasets using the OleDBDataAdapter.  The code looks something like this:
Dim ds as New Dataset
Dim adapter as New OleDBDataAdapter("SELECT * From DB", connstring)
adapter.fill(ds, "DB")

I would like to create a class that could replace the OleDBDataAdapter with my own dataadapter such as JWDataAdapter that has the ability to fill a dataset. So I could simply do a find and replace and replace everything that has OleDB with JW.  However I don't know how I could fill the dataset.  So the code would look something like this:

Dim ds as New Dataset
Dim adapter as New JWDataAdapter("SELECT * From DB", connstring)
adapter.fill(ds, "DB")


Any ideas?
johnywhiteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeff CertainCommented:
Create a class called JWDataAdapter. Implement a constructor that overloads the New. Then add a Fill method. Inside this method, use the OLEDb objects to perform the fill.

What are you trying to acheive?
0
johnywhiteAuthor Commented:
I guess what I am don't know is how to fill the dataset which is in the form calling the class.  I don't know if I am explaining myself very well.  What i am trying to do is turn an invoice program that I created into a web-enabled program.  I want the database to get the data off of my web-site through a web-service rather than have it stored on a local database.  I want to do this with minimal effort, so my thought was to create a class like stated above which gets the data off of the web-site then fills the datasets in the exact same manner that was done before.
0
Jeff CertainCommented:
The issue will be in retrieving the data from the web service... in order to return anything resembling a database record, you'll have to return XML and then parse that back into the database.

However... if the database is accessible from the web server, then you can just use the OLEDB objects to hit the database. If you're using Access (which OLEDB suggests), you'll find that there are significant issues in trying to use it for multiple simultaneous users (i.e. a web app).

When you say "get the data off the web-site," are you referring to having a form submitted to the database?

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

johnywhiteAuthor Commented:
That is not the problem.  I can do that just fine and I have already written the code to do so.  Maybe I can explain this a little better.  With the code I have written I can fill the dataset like this.

Dim mywebservice as WebService1
Dim ds as New Dataset
ds = mywebservice.fill()

The web service is a function that returns a dataset, and that works just fine.  What I want to do is fill the dataset like this instead so I don't have to rewrite a lot of other code throughout my program.

Dim ds as New Dataset
Dim adapter as New JWDataAdapter("SELECT * From DB", connstring)
adapter.fill(ds, "DB")

Where JWDataAdapter is a class that I have written which calls the WebService and fills the dataset ds.  This is what I don't know how to do.  I am quite sure that it is something incredibly simple that I am missing, but I am not sure what that is.
0
Jeff CertainCommented:
Sorry for the delay in answering. I was out of the office Friday afternoon.

If I understand correctly, you have a web service that you call with no arguments to fill a dataset, and want to find an easier way to return this dataset by using replace to avoid rewriting code? Okay... here goes.

1. Your arguments to the JWDataAdapter constructor are not going to be used. However, we'll leave them in and do nothing with them to avoid rewriting code.
2. Likewise, the arguments to the Fill method are unused.

Public Class JWDataAdapter
      Public Sub New(ByVal SQL As String, ByVal connString As String)

      End Sub

      Public Function Fill(ByVal SQL As String, ByVal connString As String) As DataSet
            Dim mywebservice As WebService1
            Dim ds As New DataSet
            ds = mywebservice.fill()
            Return ds
      End Function
End Class
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johnywhiteAuthor Commented:
I figured it out.  What I needed is to use ByRef instead of ByVal.  Like this:

Public Class JWDataAdapter
     Public Sub New(ByVal SQL As String, ByVal connString As String)

     End Sub

     Public Function Fill(ByVal ds As DataSet, ByVal table As String) As DataSet
          Dim mywebservice As WebService1
          Dim ds As New DataSet
          ds = mywebservice.fill()
          Return ds
     End Function
End Class

Then I can fill it like this:

Dim ds as New Dataset
Dim adapter as New JWDataAdapter("SELECT * From DB", connstring)
adapter.fill(ds, "DB")

Thanks for your help though.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.