Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2009, 09:50 AM
Authorized User
 
Join Date: Jul 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks to datarow cast reply

Thanks a lot, my update function is working,thanks a lot, now here's my retrieve and create function which are still complaining about the datarow when i
compile. So under the create function where "r=ds.tblDocument.NewRow" it says cannot convert method group "NewRow" to non-delegate type 'busl.tblDocumentRow' did you intend to invoke the method?

Under the retrieve Function the 'r' in for each statement says "a local variable named 'r' cannot be declared in this scope it would give a different meaning to 'r' which is already used in a parent or current to denote something else".

And one last thing in vb i was using collection(dim col as new collection) so in c# i used arraylist, i don't know if i'm going astray. I know this is too much but i need thanks in advance. Thanks a lot.

publicstring create(Docs dc)
{

busl.tblDocumentRow r;
Dbconnection cd = newDbconnection();
SqlDataAdapter adp = newSqlDataAdapter("Select * From Account", cd.con);
SqlCommandBuilder cmb = newSqlCommandBuilder(adp);
string msg;
r = ds.tblDocument.NewRow;
r.id = dc.id;
r.Description=dc.description;
r.Fpath=dc.filepath;
r.Datec = dc.dc;
r.Createdby=dc.usrC;
ds.tblDocument.Rows.Add(r);
//for all fields
adp.Update(ds.tblDocument);
ds.AcceptChanges();
msg =
"Success";
return msg;
}
publicArrayList Retrieve(string strCriteria )
{
ArrayList col = newArrayList();
Docs usr = newDocs();
busl.tblDocumentRow r;
//NullableDataReader r = New NullableDataReader();
Dbconnection cd = newDbconnection();

SqlDataAdapter adp = newSqlDataAdapter("Select * From Account Where " + strCriteria, cd.con);
SqlCommandBuilder cmb = newSqlCommandBuilder(adp);
adp.Fill(ds.tblDocument);
foreach (busl.tblDocumentRow r in ds.tblDocument.Rows)
{
usr.id = r.id;
usr.description=r.Description;
usr.filepath=r.Fpath;
usr.dc=r.Datec;
usr.usrC=r.Createdby;
usr.fieds.Add(r.id);
usr.fieds.Add(r.Description);
usr.fieds.Add(r.Fpath);
usr.fieds.Add(r.Datec);
usr.fieds.Add(r.Createdby);
col.Add(usr);
return col;
}
}
__________________
supertedz
 
Old April 20th, 2009, 09:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Thumbs up

Hello again..

r = ds.tblDocument.NewRow(); (you forget the parenthesis).

And the second error, you are defining r two times (one at the begging of the function, the second time in the foreach loop. Take out the second one.

And why no use collections in C# too? (I don't even know what for you need them, but the classes are the same.)

And also there is a thanks button at the bottom of the post. If you like the post, use it
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
DataRow.ItemArray abhi123 C# 4 June 7th, 2007 02:33 PM
Need help understanding DataRow asp_convert ADO.NET 3 March 13th, 2007 02:39 PM
insert datarow into datagrid lpl General .NET 1 March 29th, 2006 07:05 AM
Specified cast is not valid in DataRow Casting yoord BOOK: Beginning ASP.NET 1.0 23 September 21st, 2004 06:34 AM
deleting a datarow sand133 VB Databases Basics 0 July 14th, 2004 07:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.