473,387 Members | 1,548 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,387 software developers and data experts.

populating a DataTable in a DataSet

Hi,

I have done following: Add new item - Dataset, then add DataTable, and
add a few fields (VS2005) because this seems the only way to let a
Crystalreport recognize a datatable in the project.

Now the problem, should be simple but I cannot find it. How can I
populate the dataTable in code ? I don't need a connection to a
database and so.

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Nov 4 '06 #1
6 1477
Hi Wilfried,

Here's a simplified example:

"How To: Fill a DataSet with Data":
http://msdn2.microsoft.com/en-us/lib...20(VS.80).aspx

--
Dave Sexton

"Wilfried Mestdagh" <wi******@mestdagh.bizwrote in message
news:OG**************@TK2MSFTNGP02.phx.gbl...
Hi,

I have done following: Add new item - Dataset, then add DataTable, and add a
few fields (VS2005) because this seems the only way to let a Crystalreport
recognize a datatable in the project.

Now the problem, should be simple but I cannot find it. How can I populate
the dataTable in code ? I don't need a connection to a database and so.

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz

Nov 4 '06 #2
Hi Wilfried,

I'm sorry, I just realized you wrote "don't" need a connection to a database.

In that case, here's a simple example. Assuming that you have a strong-typed
DataSet named, "PeopleData" that contains a single DataTable named, "People",
which only contains a single column named, "Name" of type System.String, you
could do the following:

PeopleData data = new PeopleData();
data.People.AddPeopleRow("Joe");
data.People.AddPeopleRow("Fred");
data.AcceptChanges();

HTH

--
Dave Sexton

"Wilfried Mestdagh" <wi******@mestdagh.bizwrote in message
news:OG**************@TK2MSFTNGP02.phx.gbl...
Hi,

I have done following: Add new item - Dataset, then add DataTable, and add a
few fields (VS2005) because this seems the only way to let a Crystalreport
recognize a datatable in the project.

Now the problem, should be simple but I cannot find it. How can I populate
the dataTable in code ? I don't need a connection to a database and so.

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz

Nov 4 '06 #3
Heya Wilfried,

Daft question - but re your Crystal Report - Are you attempting to
dynamically alter the design and such of the CrystalReport proper? If so a
heads up of a headache that I had to find out the hard way - You can't with
the API and CrystalReports namespace that is shipped with VS2005...

If not ignore me :)

Brendon


"Wilfried Mestdagh" <wi******@mestdagh.bizwrote in message
news:OG**************@TK2MSFTNGP02.phx.gbl...
Hi,

I have done following: Add new item - Dataset, then add DataTable, and add
a few fields (VS2005) because this seems the only way to let a
Crystalreport recognize a datatable in the project.

Now the problem, should be simple but I cannot find it. How can I populate
the dataTable in code ? I don't need a connection to a database and so.

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Nov 4 '06 #4
Hi Dave,

Thanks I give that a try :)

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Nov 4 '06 #5
Hy Brendon,

Yes and no, but I just discovered ReportViewer witch seems very much
simpler to work with. Also it understand Object Data Sources, which I
think this is improvement. Now I have to learn these things too :)

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz

Brendon Bezuidenhout wrote:
Heya Wilfried,

Daft question - but re your Crystal Report - Are you attempting to
dynamically alter the design and such of the CrystalReport proper? If so
a heads up of a headache that I had to find out the hard way - You can't
with the API and CrystalReports namespace that is shipped with VS2005...

If not ignore me :)

Brendon


"Wilfried Mestdagh" <wi******@mestdagh.bizwrote in message
news:OG**************@TK2MSFTNGP02.phx.gbl...
>Hi,

I have done following: Add new item - Dataset, then add DataTable, and
add a few fields (VS2005) because this seems the only way to let a
Crystalreport recognize a datatable in the project.

Now the problem, should be simple but I cannot find it. How can I
populate the dataTable in code ? I don't need a connection to a
database and so.

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Nov 4 '06 #6
Here is an alternate way (not using strongly typed):

DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("TEST");
DataRow row ;
for(int i = 0;i<3;i++)
{
row=dt.NewRow();
row["TEST"] ="Howdy " +i.ToString();
dt.Rows.Add(row);
}
ds.Tables.Add(dt);

Done! Cheers,

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Wilfried Mestdagh" wrote:
Hi,

I have done following: Add new item - Dataset, then add DataTable, and
add a few fields (VS2005) because this seems the only way to let a
Crystalreport recognize a datatable in the project.

Now the problem, should be simple but I cannot find it. How can I
populate the dataTable in code ? I don't need a connection to a
database and so.

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Nov 4 '06 #7

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

Similar topics

3
by: Mico | last post by:
I would be very grateful for any help with the following problem: I use a DataAdapter to fill a DataSet in the Page_Load method. Later, I use this DataSet to construct a DataTable, then create...
2
by: Ricardo Luceac | last post by:
HI all.. I have a huge table that I want to display in a datagrid, the problem is that if I make a dataset, the entire table must go to the dataset to the data begin to display, and it takes...
2
by: Robert | last post by:
I'm sure this is a fairly basic question, but I've been looking all over the web for days for suggestions on how to do this. I've got a datagrid that's bound to a dataset on my form. It includes...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
by: MicroMoth | last post by:
I know that this is probably a simple question, but I can't seem to find out how to populate the form fields I have with the results from my stored procedure, which I have stored in a datase. I...
0
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create...
3
by: babu17 | last post by:
hi , I have a database table with 3 columns table1: eid ename parentid 0 root 0 1 child1 0 2 child2 0
0
JordanMartz
by: JordanMartz | last post by:
''' <summary> ''' Populates the DataGridView ''' </summary> Private Sub PopulateDataGridView() ' Set the column header names. userAccessGrid.ColumnCount = 5 ...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.