or return object []
public object[] Function()
{
}
Main Topics
Browse All TopicsHi,
I am creating a small application with a database class to handle all db requests in c#. The part I am stuck on is querying the database.
I am using the MySQL .net connector and can so far query the database but cannot find a way to return the rows through the class? I was thinking of returning it just through the method but I've realised that it can only return one function.
Anyone have any ideas on what I could do?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I usually have my datalayer translate a set of rows into a collection of DataEntities.
The database call would then e.g. return a List<Person>
A Person class would have properties like Name, Age and such and would know how to transform itself from a datarow into itself (by implementing a static method on the person class)
The DAL method would get a dataset out of the database, and loop through the rows and call the transformation method for each row and would add a new person to the result list.
When done, return the list.
There are two ways you can return multiple values from a method.
1. ByRef
2. Out
ByRef is basically when you populate with initial values into IN parameters whereas out is when you just expect the results but don't have any initial data to popoulate the parameters. ject references.
public void Add( int x, int y, out int sum)
{
sum = x + y;
}
public void CopyTo( MyClass x, ByRef MyClass target)
{
target = new MyClass( x ); // assuming that MyClass supports creating new instances based on object instance
}
I support PockyMaster's idea. I usually have a Busines Layer. The DAL returns dataset/datareader (it doesn't do transformation) The Business Layer contains classes that represent your database objects. i.e employee, order, product as well general classes like say UserSession which will include your collections List<Employee> List<Order> etc.
Now your GUI will create a new UserSession then call something like GetOrders of UserSession. The GetOrders method will fire the DAL, get a dataset/datareader back. Iterate through that and fill it's List<Order> member. The GetOrders method returns true/false for success/failure. On returning true you can access the collection. Now at any time later on other forms I can still access UserSession's collections (this is useful for info that doesn't change very often).
Business Accounts
Answer for Membership
by: indianguru2Posted on 2008-01-29 at 02:32:15ID: 20766656
Have you heard of something called ByRef
/en-us/lib rary/ c84t7 3c2(VS.71) .aspx
http://msdn2.microsoft.com