PC Review


Reply
Thread Tools Rate Thread

How can i use a dataset w/o a datasource?

 
 
forest demon
Guest
Posts: n/a
 
      10th Jan 2008
what i'm trying to do is attach a report file to a reportviewer
instance with some values from a page. i can attach a dataset to
the .rdlc file with stuff from a datasource, but i need to also add
values form a pages web controls to the same report.

it was recommended, on here, that i create a dataset in memory and add
that to the report. i'm not sure how to do that at this point without
a datasource. i'm drawing a blank.

thanks to all who reply....

-
fd
 
Reply With Quote
 
 
 
 
Alberto Poblacion
Guest
Posts: n/a
 
      10th Jan 2008
"forest demon" <(E-Mail Removed)> wrote in message
news:f159c9fb-459c-4e6a-a865-(E-Mail Removed)...
> what i'm trying to do is attach a report file to a reportviewer
> instance with some values from a page. i can attach a dataset to
> the .rdlc file with stuff from a datasource, but i need to also add
> values form a pages web controls to the same report.
>
> it was recommended, on here, that i create a dataset in memory and add
> that to the report. i'm not sure how to do that at this point without
> a datasource. i'm drawing a blank.


Simply build the dataset step by step by adding to its collections in
your code:

DataSet ds = new DataSet();
DataTable dt = new DataTable("name");
ds.Tables.Add(dt);
dt.Columns.Add("Col1", typeof(string));
dt.Columns.Add("Col2", typeof(int));
dt.Rows.Add(new object[]{"value1", 123});
dt.Rows.Add(new object[]{"value2", 456});
//Now ds is a dataset that contains one table with two columns and two rows


 
Reply With Quote
 
forest demon
Guest
Posts: n/a
 
      10th Jan 2008
On Jan 9, 11:25*pm, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.org> wrote:
> "forest demon" <mete.ha...@gmail.com> wrote in message
>
> news:f159c9fb-459c-4e6a-a865-(E-Mail Removed)...
>
> > what i'm trying to do is attach a report file to a reportviewer
> > instance with some values from a page. i can attach a dataset to
> > the .rdlc file with stuff from a datasource, but i need to also add
> > values form a pages web controls to the same report.

>
> > it was recommended, on here, that i create a dataset in memory and add
> > that to the report. *i'm not sure how to do that at this point without
> > a datasource. *i'm drawing a blank.

>
> * * Simply build the dataset step by step by adding to its collectionsin
> your code:
>
> DataSet ds = new DataSet();
> DataTable dt = new DataTable("name");
> ds.Tables.Add(dt);
> dt.Columns.Add("Col1", typeof(string));
> dt.Columns.Add("Col2", typeof(int));
> dt.Rows.Add(new object[]{"value1", 123});
> dt.Rows.Add(new object[]{"value2", 456});
> //Now ds is a dataset that contains one table with two columns and two rows


thanks for the input. i'm able to make this work now....

 
Reply With Quote
 
forest demon
Guest
Posts: n/a
 
      10th Jan 2008
On Jan 9, 11:25*pm, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.org> wrote:
> "forest demon" <mete.ha...@gmail.com> wrote in message
>
> news:f159c9fb-459c-4e6a-a865-(E-Mail Removed)...
>
> > what i'm trying to do is attach a report file to a reportviewer
> > instance with some values from a page. i can attach a dataset to
> > the .rdlc file with stuff from a datasource, but i need to also add
> > values form a pages web controls to the same report.

>
> > it was recommended, on here, that i create a dataset in memory and add
> > that to the report. *i'm not sure how to do that at this point without
> > a datasource. *i'm drawing a blank.

>
> * * Simply build the dataset step by step by adding to its collectionsin
> your code:
>
> DataSet ds = new DataSet();
> DataTable dt = new DataTable("name");
> ds.Tables.Add(dt);
> dt.Columns.Add("Col1", typeof(string));
> dt.Columns.Add("Col2", typeof(int));
> dt.Rows.Add(new object[]{"value1", 123});
> dt.Rows.Add(new object[]{"value2", 456});
> //Now ds is a dataset that contains one table with two columns and two rows


should i cast the value prior to adding it to the row?
if not, i get the DataRow type when trying to use the text value in
the array.

thanks...
 
Reply With Quote
 
forest demon
Guest
Posts: n/a
 
      10th Jan 2008
On Jan 10, 12:22*am, forest demon <mete.ha...@gmail.com> wrote:
> On Jan 9, 11:25*pm, "Alberto Poblacion" <earthling-
>
>
>
>
>
> quitaestoparacontes...@poblacion.org> wrote:
> > "forest demon" <mete.ha...@gmail.com> wrote in message

>
> >news:f159c9fb-459c-4e6a-a865-(E-Mail Removed)...

>
> > > what i'm trying to do is attach a report file to a reportviewer
> > > instance with some values from a page. i can attach a dataset to
> > > the .rdlc file with stuff from a datasource, but i need to also add
> > > values form a pages web controls to the same report.

>
> > > it was recommended, on here, that i create a dataset in memory and add
> > > that to the report. *i'm not sure how to do that at this point without
> > > a datasource. *i'm drawing a blank.

>
> > * * Simply build the dataset step by step by adding to its collections in
> > your code:

>
> > DataSet ds = new DataSet();
> > DataTable dt = new DataTable("name");
> > ds.Tables.Add(dt);
> > dt.Columns.Add("Col1", typeof(string));
> > dt.Columns.Add("Col2", typeof(int));
> > dt.Rows.Add(new object[]{"value1", 123});
> > dt.Rows.Add(new object[]{"value2", 456});
> > //Now ds is a dataset that contains one table with two columns and two rows

>
> should i cast the value prior to adding it to the row?
> if not, i get the DataRow type when trying to use the text value in
> the array.
>
> thanks...- Hide quoted text -
>
> - Show quoted text -


oh geesh...nevermind. i figured it out. sorry....

thanks again for your help. i do appreciate it.

-
fd
 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      10th Jan 2008

You can also create a (strongly typed) dataset. And get strong typing.

Start a new Console Application:

Add / New Item / DataSet.

Call it "EmployeeDS". (or EmployeeDS.xsd)

Right click (in the design area) ... Add a table. "Employee"

Add 3 columns

ID (int)
LastName (string)
FirstName (string)


...
then you can "code up" a version like this

EmployeeDS ds = new EmployeeDS();

//first way
ds.Employee.AddNewEmployeeRow ( 123, "Smith" , "John");
//second way
EmployeeDS.Employee.EmployeeRow newRow = ds.Employee.NewEmployeeRow();
newRow.ID = 234;
newRow.LastName = "Jones";
newRow.FirstName = "Mary";

ds.Employee.AddNewEmployeeRow ( newRow ) ;

string x = ds.GetXml();


I do that all the time for UnitTests, and testing code without talking to
the database.

Good luck.






"forest demon" <(E-Mail Removed)> wrote in message
news:f159c9fb-459c-4e6a-a865-(E-Mail Removed)...
> what i'm trying to do is attach a report file to a reportviewer
> instance with some values from a page. i can attach a dataset to
> the .rdlc file with stuff from a datasource, but i need to also add
> values form a pages web controls to the same report.
>
> it was recommended, on here, that i create a dataset in memory and add
> that to the report. i'm not sure how to do that at this point without
> a datasource. i'm drawing a blank.
>
> thanks to all who reply....
>
> -
> fd



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset or datasource control? Jason James Microsoft ADO .NET 0 1st May 2006 02:24 PM
why can I set grid's DataSource to a DataSet but not to a table in the DataSet? Bennett Haselton Microsoft ADO .NET 1 25th Jul 2004 08:24 AM
Using ADO.NET dataset as report datasource Tor Inge Rislaa Microsoft VB .NET 0 14th Oct 2003 11:40 AM
DataSource without DataSet? Peter Rabbit Microsoft ADO .NET 2 17th Jul 2003 09:03 PM
cast datagrid.datasource to dataset (datasource is table) newsgroper@yahoo.com Microsoft Dot NET Framework Forms 1 4th Jul 2003 04:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:39 PM.