Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / June 2004

Tip: Looking for answers? Try searching our database.

datatable.newrow HOW THE HELL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Al Bastido - 11 Jun 2004 13:02 GMT
could somebody please explain to me how the datatable.newrow method works, i've been trying to figure it out for weeks. I need to emulate it myself.

I can bind my datagrid to a collection of objects with no problem. But that leaves me with a fixed number of properties per object and therefore a fixed number of columns in my datagrid.

I wanted to do something similar to the datatable, where you add columns then have a method that generates a row object based on the column schema.

The reason i want to do this is to be able to hold objects in the table rather than scalar value as the datatable does.

Thanks in advance -  i'm getting to the stage of dispear
)
scorpion53061 - 11 Jun 2004 13:39 GMT
Dim dro as DataRow = someDataTable.NewRow
DataRow dro = someDataTable.NewRow();

'add the values respectively for each field

finally,
someDataTable.Rows.Add(dro);
//same for c# in this case.

Then just call DataAdapter.Update

There's a bunch that coudl be going wrong.  How have you tried to add
the
rows?  Are you getting any exceptions? (Make sure you don't have any
try/catch blocks that don't do anything but eat the exception

Also verify that you DataSet.hasChanges

Cheers,

Bill Ryan

> could somebody please explain to me how the datatable.newrow method works,
> i've been trying to figure it out for weeks. I need to emulate it myself.
[quoted text clipped - 18 lines]
>
> <Id>ZByFf79PG0qF06z7hawZIg==</Id
William Ryan eMVP - 11 Jun 2004 14:10 GMT
It'd help if you posted what you were currently doing, but this is
essentially the snytax:

C#
DataRow dro = DataTableName.NewRow();
dro[0] = "whatever";
dro[1] = "you get the idea";
DataTableName.Rows.Add(dro);

VB.NET
Dim dro as DataRow = new DataRow
dro(0) = "whatever"
dro(1) = "you get the idea"
DataTableName.Rows.Add(dro)
Signature


With that said, I'm not sure how it relates to your problem.  If you bind to
a datatable or a collection, you can add new values to it. If you
implemented a strongly typed collection then it would be quite easy, just
define a new instance of the object.  As far as the columns go, I don't see
how it's any different other than not being as clean as  a datatable. In
most instances, you can model quite a few things using a datatable directly.
If you look at what most ORM tools like Deklarit and LLBLGen do, the
effectively make the bridge between your object(s) and the dataTables(s),
which you can certainly do on your own although using one of those two tools
makes it a dream.  You can get a good idea of how a datatable is implemented
by looking at its structure in the documentation.   I may have misunderstood
your question though and If I did, please let me konw and I'll see what I
can do.

Cheers,

Bill

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/

> could somebody please explain to me how the datatable.newrow method works, i've been trying to figure it out for weeks. I need to emulate it myself.
>
> I can bind my datagrid to a collection of objects with no problem. But that leaves me with a fixed number of properties per object and therefore a
fixed number of columns in my datagrid.

> I wanted to do something similar to the datatable, where you add columns then have a method that generates a row object based on the column schema.
>
[quoted text clipped - 9 lines]
>
> <Id>ZByFf79PG0qF06z7hawZIg==</Id
Cowboy \(Gregory A. Beamer\) [MVP] - 11 Jun 2004 14:18 GMT
New row simply creates a new row with a specific set of columns. You still
have to fill it and bind it back to the DataTable. I have a sample
somewhere. I will see if I can dig it up.

Signature

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************

> could somebody please explain to me how the datatable.newrow method works, i've been trying to figure it out for weeks. I need to emulate it myself.
>
> I can bind my datagrid to a collection of objects with no problem. But that leaves me with a fixed number of properties per object and therefore a
fixed number of columns in my datagrid.

> I wanted to do something similar to the datatable, where you add columns then have a method that generates a row object based on the column schema.
>
[quoted text clipped - 9 lines]
>
> <Id>ZByFf79PG0qF06z7hawZIg==</Id
Cor Ligthert - 11 Jun 2004 14:57 GMT
Hi Al,

In addition to the others, this is a very intresting page about the datarow
and his version states.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conrowstates.asp


I hope this helps?

Cor

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.