J
JS
I'm trying to create a data layer and having problems returning a DataSet
from my code that's in a class module.
Please forgive me. I'm new to C# (VB'er). I decided to create my data layer
in small steps. Right now, I'm just trying to attach a ComboBox to a dataset
that's in my class module. In the class, I call a Stored Procedure. I know
how to set up the connection, command, adapter, and dataset, what I'm having
a problem with is, telling the method in my class to return the dataset to
the caller.
In VB I could return the dataset by creating a function like such:
This code is in a class module.
Function ShowVendors() as DataSet
Connection
Command code
Adapter code
Return myDataSet
End Function
I then set the ComboBox datasource to ShowVendors(). Works like a charm.
But, I cannot for the life of me get ShowVendors() to return the dataset
back to the caller in C# I have seen and tried a million examples (give or
take a hundred or so) examples on how to bind a control to a dataset, but I
don't know how many more "Console.WriteLine" or code behind the form
examples I can take. I want to keep all of my database connections totally
separate from my forms.
So, I guess my question is two part. How do I return a dataset from my data
layer, and is returning a dataset like I'm trying to here a good or bad
design approach?
Any help on this would be greatly appreciated. TIA,
- JS -
from my code that's in a class module.
Please forgive me. I'm new to C# (VB'er). I decided to create my data layer
in small steps. Right now, I'm just trying to attach a ComboBox to a dataset
that's in my class module. In the class, I call a Stored Procedure. I know
how to set up the connection, command, adapter, and dataset, what I'm having
a problem with is, telling the method in my class to return the dataset to
the caller.
In VB I could return the dataset by creating a function like such:
This code is in a class module.
Function ShowVendors() as DataSet
Connection
Command code
Adapter code
Return myDataSet
End Function
I then set the ComboBox datasource to ShowVendors(). Works like a charm.
But, I cannot for the life of me get ShowVendors() to return the dataset
back to the caller in C# I have seen and tried a million examples (give or
take a hundred or so) examples on how to bind a control to a dataset, but I
don't know how many more "Console.WriteLine" or code behind the form
examples I can take. I want to keep all of my database connections totally
separate from my forms.
So, I guess my question is two part. How do I return a dataset from my data
layer, and is returning a dataset like I'm trying to here a good or bad
design approach?
Any help on this would be greatly appreciated. TIA,
- JS -