473,790 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compile error when DataRow used as base class

here is a simple class:

public class Demo1 : System.Data.Dat aRow
{
public Demo1()
{
}
}

but it does not compile:
C:\src#\Steve\D emo1.cs(10): No overload for method 'DataRow'
takes '0' arguments

Am I not able to subclass the DataRow class?

thanks,
-Steve

Nov 17 '05 #1
7 5767
Hi Steve,

The constructor for a DataRow is defined as:

protected internal DataRow( DataRowBuilder builder );

Change your class to say:

using System;
using System.Data;
....
public class Demo1 : DataRow
{
public Demo1( DataRowBuilder builder ) : base( builder )
{
}
}
....

Daryush

"Steve Richter" wrote:
here is a simple class:

public class Demo1 : System.Data.Dat aRow
{
public Demo1()
{
}
}

but it does not compile:
C:\src#\Steve\D emo1.cs(10): No overload for method 'DataRow'
takes '0' arguments

Am I not able to subclass the DataRow class?

thanks,
-Steve

Nov 17 '05 #2
Steve Richter <St************ @gmail.com> wrote:
here is a simple class:

public class Demo1 : System.Data.Dat aRow
{
public Demo1()
{
}
}

but it does not compile:
C:\src#\Steve\D emo1.cs(10): No overload for method 'DataRow'
takes '0' arguments

Am I not able to subclass the DataRow class?


See http://www.pobox.com/~skeet/csharp/constructors.html

Your code is equivalent to:

public class Demo1 : System.Data.Dat aRow
{
public Demo1() : base()
{
}
}

and as there isn't a parameterless constructor available, you get a
compiler error.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #3

Daryush wrote:
Hi Steve,

The constructor for a DataRow is defined as:

protected internal DataRow( DataRowBuilder builder );

Change your class to say:

using System;
using System.Data;
...
public class Demo1 : DataRow
{
public Demo1( DataRowBuilder builder ) : base( builder )
{
}
}


great! thank you.

Now the big question, a brief answer from anyone will be ok with me,:
I can subclass DataTable
class MyTable : DataTable
{
}

and I can subclass DataRow
class MyRow : DataRow
{
public MyRow( DataRowBuilder builder ) : base( builder )
{
}
}

how do I program MyTable.NewRow( ) to return a "MyRow" object instead
of a "DataRow" object?

-Steve

Nov 17 '05 #4
Steve Richter <St************ @gmail.com> wrote:
great! thank you.

Now the big question, a brief answer from anyone will be ok with me,:
I can subclass DataTable
class MyTable : DataTable
{
}

and I can subclass DataRow
class MyRow : DataRow
{
public MyRow( DataRowBuilder builder ) : base( builder )
{
}
}

how do I program MyTable.NewRow( ) to return a "MyRow" object instead
of a "DataRow" object?


I believe the right thing to do is override NewRowFromBuild er to return
the appropriate type of row, and NewRow will call NewRowFromBuild er
with the appropriate DataRowBuilder. I've never done it myself
though...

You might want to get VS.NET to generate a strongly typed data set
(with any old schema) and have a look at what the generated code looks
like - that should give you a reasonable idea of what's required.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #5

Jon Skeet [ C# MVP ] wrote:
Steve Richter <St************ @gmail.com> wrote:
great! thank you.

Now the big question, a brief answer from anyone will be ok with me,: I can subclass DataTable
class MyTable : DataTable
{
}

and I can subclass DataRow
class MyRow : DataRow
{
public MyRow( DataRowBuilder builder ) : base( builder )
{
}
}

how do I program MyTable.NewRow( ) to return a "MyRow" object instead of a "DataRow" object?
I believe the right thing to do is override NewRowFromBuild er to

return the appropriate type of row, and NewRow will call NewRowFromBuild er
with the appropriate DataRowBuilder. I've never done it myself
though...

You might want to get VS.NET to generate a strongly typed data set
(with any old schema) and have a look at what the generated code looks like - that should give you a reasonable idea of what's required.


thank you, Jon.

What I am looking to do is have a property in MyRow for each column in
the table. Using an indexer to get and set objects in the
DataRowCollecti on seems nuts to me, too much hardcoding of names.

I would much prefer:
row.EmpID = 25 ;

over
row["EmpID"] = 25 ;

-Steve

Nov 17 '05 #6
Steve Richter <St************ @gmail.com> wrote:
What I am looking to do is have a property in MyRow for each column in
the table. Using an indexer to get and set objects in the
DataRowCollecti on seems nuts to me, too much hardcoding of names.

I would much prefer:
row.EmpID = 25 ;

over
row["EmpID"] = 25 ;


You might want to look at getting VS.NET to generate a strongly typed
dataset for you, unless you have a particular reason to write all the
code yourself - it would at least be a good starting point.

(Using non-strongly-typed datasets isn't too bad so long as you don't
put the literals in the code, but use constants defined elsewhere - or
even better, fetch the DataColumn and use that, as it would be more
efficient.)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #7

Jon wrote:
Steve Richter <St************ @gmail.com> wrote:
great! thank you.

Now the big question, a brief answer from anyone will be ok with me,: I can subclass DataTable
class MyTable : DataTable
{
}

and I can subclass DataRow
class MyRow : DataRow
{
public MyRow( DataRowBuilder builder ) : base( builder )
{
}
}

how do I program MyTable.NewRow( ) to return a "MyRow" object instead of a "DataRow" object?
I believe the right thing to do is override NewRowFromBuild er to

return the appropriate type of row, and NewRow will call NewRowFromBuild er
with the appropriate DataRowBuilder. I've never done it myself
though...
These guys have:
http://www.dotnet247.com/247reference/msgs/1/5843.aspx

you have to override the virtual functions "NewRowFromBuil der" and
"GetRowType ". After that it works!

-Steve

You might want to get VS.NET to generate a strongly typed data set
(with any old schema) and have a look at what the generated code looks like - that should give you a reasonable idea of what's required.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 17 '05 #8

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

Similar topics

0
1665
by: Zach | last post by:
Using Dev-C++ 4.9.8.5 I get error: Compiler: Default compiler Executing g++.exe... g++.exe "C:\winroot\src\c++\stupid_tricks\functor_trick.cpp" -o "C:\winroot\src\c++\stupid_tricks\functor_trick.exe" -I"C:\DEV-CPP\include\c++" -I"C:\DEV-CPP\include\c++\mingw32" -I"C:\DEV-CPP\include\c++\backward" -I"C:\DEV-CPP\include" -L"C:\DEV-CPP\lib" C:/winroot/src/c++/stupid_tricks/functor_trick.cpp: In member function
2
3470
by: Tony Johansson | last post by:
Hello Experts! I have been playing around a bit with this multiple inheritance and I wonder why do I get a compile error if I remove the virtual keyvord from the declaration of the Student class and the Employee class. I have removed all kind of data from all classes. The compile error occur when I instansiate Person* p = new TeachingAssistent; The error I get is c:\Documents and
5
3823
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace ) Person.xsd includes Common-Naming.xsd ( anonimous schemas ) Common-Naming.xsd includes common.xsd ( both are anonimous schemas ) Compilation of Resident.xsd raise the following exception: "System.Xml.Schema.XmlSchemaException: The attribute 'oid'...
6
4411
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the same invocation from a DistantlyRelated class. What actually happened was that the compiler produced: error C2247: 'A::function' not accessible because 'CloselyRelated' uses 'private' to inherit from 'A' I'm guessing that the above compiler...
0
4806
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having manually inserted a row in the table bound to the Combo box. The InsertAt Method of adding a row just does not work. Hope this helps anyone with this problem. john
8
2478
by: ST | last post by:
Hello everyone, Can anyone help me with this error above when I debug my web app project in vstudio.net?? I can't figure it out! It was working fine for months, and now all of a sudden it's not!! This is the error: biopsy.searchsubject.btnSubject_Click(Object Sender, EventArgs e) in C:\INetPub\WWWRoot\biopsy\searchsubject.aspx.vb:198 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
8
1312
by: Mark | last post by:
Hi, I have two classes: template <class Resourceclass GuardBase { protected : Resource& fResource; bool fAcquired;
5
1965
by: Michael | last post by:
Hi All, I have three very simple files as below. When I try and compile these with g++ -ansi -Wall -pedantic -o crap Base.h Other.h I get an error: Base.h:7: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate.
16
5433
by: desktop | last post by:
I have read that using templates makes types know at compile time and using inheritance the types are first decided at runtime. The use of pointers and casts also indicates that the types will first be know at runtime. But is there some strict definitions that defines runtime code and compile time code that can be used in general?
0
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9986
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.