473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

same return types ? DataSet & SqlDataReader

Hi, is this not possible?

public DataSet getDimensions()
{
}

public SqlDataReader getDimensions()
{
}

I get this error on compile: "Class 'ProductFamily' already defines a
member called 'getDimensions' with the same parameter types"

-- Doesnt seem right to me --
Nov 16 '05 #1
13 2465
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
Hi, is this not possible?
No.
public DataSet getDimensions()
{
}

public SqlDataReader getDimensions()
{
}

I get this error on compile: "Class 'ProductFamily' already defines a
member called 'getDimensions' with the same parameter types"

-- Doesnt seem right to me --


Why not? Which would you expect to be called in this case:

object o = getDimensions();

or even just

getDimensions();

?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Jon Skeet [C# MVP] wrote:
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
Hi, is this not possible?


No.
public DataSet getDimensions()
{
}

public SqlDataReader getDimensions()
{
}

I get this error on compile: "Class 'ProductFamily' already defines a
member called 'getDimensions' with the same parameter types"

-- Doesnt seem right to me --


Why not? Which would you expect to be called in this case:

object o = getDimensions();

or even just

getDimensions();


I was under the impression that I could overload on return type

DataSet ds = getDimensions()
SqlDataReader dr = getDimensions()

Nov 16 '05 #3
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
I was under the impression that I could overload on return type

DataSet ds = getDimensions()
SqlDataReader dr = getDimensions()


No, you can't.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Jon Skeet [C# MVP] wrote:
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
I was under the impression that I could overload on return type

DataSet ds = getDimensions()
SqlDataReader dr = getDimensions()


No, you can't.


Heh, yes now I know.

Jon, have you ever seen this error with respect to gatagrid and a dataset?

"Cannot create a child list for field dimensions."

Zero mention on google.
Nov 16 '05 #5
Adie wrote:
Jon Skeet [C# MVP] wrote:
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
I was under the impression that I could overload on return type

DataSet ds = getDimensions()
SqlDataReader dr = getDimensions()


No, you can't.


Heh, yes now I know.

Jon, have you ever seen this error with respect to gatagrid and a dataset?

"Cannot create a child list for field dimensions."

Zero mention on google.


Ok forget that, I seem to have got it working.
Nov 16 '05 #6
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
Jon, have you ever seen this error with respect to gatagrid and a dataset?

"Cannot create a child list for field dimensions."

Zero mention on google.


Can't say I've ever seen it. What were you trying to do at the time?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7
Jon Skeet [C# MVP] wrote:
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
Jon, have you ever seen this error with respect to gatagrid and a dataset?

"Cannot create a child list for field dimensions."

Zero mention on google.


Can't say I've ever seen it. What were you trying to do at the time?


Ok, this is the error "Cannot create a child list for field [DataSetName]"
which I called "dimensions". I was trying to bind that dataset to the grid,
like this:

DataSet ds = product.getDataSetDimensions();
_DataGrid = new DataGrid();
_Form.Controls.Add(_DataGrid);

// this commented out code works
//// DataTable dt = ds.Tables[0];
//// _DataGrid.DataSource = dt;

// this causes the error
_DataGrid.SetDataBinding(ds,"dimensions");

I think I need to spend more time reading up on the controls and ADO.
Nov 16 '05 #8
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
Ok, this is the error "Cannot create a child list for field [DataSetName]"
which I called "dimensions". I was trying to bind that dataset to the grid,
like this:

DataSet ds = product.getDataSetDimensions();
_DataGrid = new DataGrid();
_Form.Controls.Add(_DataGrid);

// this commented out code works
//// DataTable dt = ds.Tables[0];
//// _DataGrid.DataSource = dt;

// this causes the error
_DataGrid.SetDataBinding(ds,"dimensions");

I think I need to spend more time reading up on the controls and ADO.


Hmm... not sure then, I'm afraid. The table in the dataset is
definitely called dimensions?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #9
Jon Skeet [C# MVP] wrote:
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
Ok, this is the error "Cannot create a child list for field [DataSetName]"
which I called "dimensions". I was trying to bind that dataset to the grid,
like this:

DataSet ds = product.getDataSetDimensions();
_DataGrid = new DataGrid();
_Form.Controls.Add(_DataGrid);

// this commented out code works
//// DataTable dt = ds.Tables[0];
//// _DataGrid.DataSource = dt;

// this causes the error
_DataGrid.SetDataBinding(ds,"dimensions");

I think I need to spend more time reading up on the controls and ADO.


Hmm... not sure then, I'm afraid. The table in the dataset is
definitely called dimensions?


Right, well this's where I may be confused. When I created the DataSet I
just called it "dimensions" instead of the actual table name. Maybe this is
why referring to the table via the index works. I thought I could use the
name as a sort of tag or alias being a query can span more than one table.

Here's the jist of what I did:

class GenericData
{
// helper class that allows me to query and add
// any name
public DataSet getDataSetByString(string sql, string dataSetName)
{
SqlConnection mySQLCon = new SqlConnection(@"####");
SqlDataAdapter myAdapter = new SqlDataAdapter();
mySQLCon.Open();
SqlCommand myCommand = new SqlCommand(sql, mySQLCon);
myCommand.CommandType = CommandType.Text;
myAdapter.SelectCommand = myCommand;
DataSet ds = new DataSet(dataSetName); // name the dataset here
myAdapter.Fill(ds);
return ds;
}
}

class ProductFamily
{
public DataSet getDataSetDimensions()
{
GenericData sqlGD = new GenericData();
if (_productType != "")
{
return sqlGD.getDataSetByString(@"SELECT "
+ dimensionArrayToString() + // holds an array of fields for the product
" FROM products WHERE [Product Line] = '"
+ _productType + "' ORDER BY [Product Id];",
"dimensions"); // <-- DataSetName named here on the function call
}
else
{
return sqlGD.returnDataSetNull(); // jiggery pokery, returns a null
// to test against
}
}
}

class DataFormatter
{
public DataFormatter (Form form)
{
_Form = form;
}
public formatProductData(ProductFamily product)
{
DataSet ds = product.getDataSetDimensions();
_DataGrid = new DataGrid();
_Form.Controls.Add(_DataGrid);
DataTable dt = ds.Tables[0];
_DataGrid.DataSource = dt;
}
}

It's basically the fallout from a conversation I had with you a while back
on how to treat products in a database which have a variety of different
attributes, such as width, height, lenght, etc x 100.

I opted for the "wide table" you said you had seperate tables for each
product type/family -- now I spend my time working out how to dynamically
update and display the product data.
Nov 16 '05 #10
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
Hmm... not sure then, I'm afraid. The table in the dataset is
definitely called dimensions?
Right, well this's where I may be confused. When I created the DataSet I
just called it "dimensions" instead of the actual table name.


Hang on a sec - there's a big difference between a DataSet and a
DataTable. A DataSet is a *collection* of tables - and in your binding,
you're saying to find the table called "dimensions" within the DataSet.

Maybe this is why referring to the table via the index works. I thought I could use the
name as a sort of tag or alias being a query can span more than one table.

Here's the jist of what I did:

class GenericData
{
// helper class that allows me to query and add
// any name
public DataSet getDataSetByString(string sql, string dataSetName)
{
SqlConnection mySQLCon = new SqlConnection(@"####");
SqlDataAdapter myAdapter = new SqlDataAdapter();
mySQLCon.Open();
SqlCommand myCommand = new SqlCommand(sql, mySQLCon);
myCommand.CommandType = CommandType.Text;
myAdapter.SelectCommand = myCommand;
DataSet ds = new DataSet(dataSetName); // name the dataset here
myAdapter.Fill(ds);
return ds;
}
}
Ah - that will have created a table called "Table", I believe.

I personally use data adapters to fill tables, and add those tables to
DataSets separately. So, I'd use:

DataTable table = new DataTable("dimensions");
myAdapter.Fill(table);
ds.Tables.Add(table);

I find this a bit easier to manage.
It's basically the fallout from a conversation I had with you a while back
on how to treat products in a database which have a variety of different
attributes, such as width, height, lenght, etc x 100.


Ah, right. Don't remember that off-hand, I'm afraid, but hopefully the
above will help you.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #11
Adie <ar*******@h-o-t-m-a-i-l.com> wrote in message news:<16***************@hairypie.net>...
Hi, is this not possible?

public DataSet getDimensions()
{
}

public SqlDataReader getDimensions()
{
}


The compiler is correct. It is not possible. You need to provide
different parameters in order to overload the methods.

-Chris
Nov 16 '05 #12
Jon Skeet [C# MVP] wrote:
Adie <ar*******@h-o-t-m-a-i-l.com> wrote:
I personally use data adapters to fill tables, and add those tables to
DataSets separately. So, I'd use:

DataTable table = new DataTable("dimensions");
myAdapter.Fill(table);
ds.Tables.Add(table);

I find this a bit easier to manage.


Yeah, I can see that's a little more transparent.
It's basically the fallout from a conversation I had with you a while back
on how to treat products in a database which have a variety of different
attributes, such as width, height, lenght, etc x 100.


Ah, right. Don't remember that off-hand, I'm afraid, but hopefully the
above will help you.


Well I found another way of tackling the problem, but yes, as *always*,
helpful, thanks.
Nov 16 '05 #13
Chris Baldwin wrote:
Adie <ar*******@h-o-t-m-a-i-l.com> wrote in message news:<16***************@hairypie.net>...
Hi, is this not possible?

public DataSet getDimensions()
{
}

public SqlDataReader getDimensions()
{
}


The compiler is correct. It is not possible. You need to provide
different parameters in order to overload the methods.


I don't know why I thought it different than C++, moment of madness I
guess.
Nov 16 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: zarish | last post by:
hi i am trying to return a recordset from my web service to my c# app. public SQLDataReader getAllCities() { string sqlQuery = "select CityName from city"; SqlCommand comm = new...
7
by: Shaine Fisher | last post by:
I have had a look around but I'm either not finding or not seeing the answer to this, what i want to do is reurn the results as an array, or some other worldly useful format that flash mx2004 can...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
1
by: Patrick.O.Ige | last post by:
I have been paging with DataSet using "DataGridPageChangedEventArgs" and i guess it works with only Dataset because default paging requires that the DataGrid be able to determine the number of...
2
by: epigram | last post by:
I'd like to know when a DataSet is the preferred way to retrieve, and specifically update/delete, data in an ASP.NET application. I've been using straight SQL by using the SqlCommand and...
1
by: Avon | last post by:
Hi there, I am very sorry for my not perfect English. I've got very simple question. Is it possible to have stored procedure with 2 result tables and then from my application to refer to this...
2
by: Hrvoje Voda | last post by:
I'm using this store procedure to return data from sql server. SqlDataReader sqlRead = null; System.Data.SqlClient.SqlCommand ProfileBLOBSelect = new System.Data.SqlClient.SqlCommand(); ...
2
by: whitethomas12 | last post by:
Hi, I currently have some basic code that allows me to run the tracert command through VB.NET and it also updates my database based on the results. I was wondering if someone can help me...
4
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a DataSet with one table filled. From this DataSet (DataTable), I need to create a SqlDataReader. Does anybody knows how to do this ? Is it possible ?? Thanks for any help.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.