473,769 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSet in C#?

6 New Member
How to make a own dataview in c#? Can someone please help me? I want to get id and users and everything else from database to be showed in the same place at the same time just as DataView. Please help me. Need help for this. I can't find anything that I can use on google. I have searched for Howto make a dataset in c# but I'm new to programming. So please help me. =)
Dec 2 '09 #1
8 2326
tlhintoq
3,525 Recognized Expert Specialist
Database How two parts 1 and 2
http://bytes.com/topic/net/insights/...e-your-program
http://bytes.com/topic/net/insights/...rogram-part-ii
Dec 2 '09 #2
tkjensen
6 New Member
I see the form you refer to there but can't I make it my own? I don't want to use dataGridView. I want to make it my own with sql connection. But I can't get it to work. I want to play a loop thing I think.
Dec 2 '09 #3
tlhintoq
3,525 Recognized Expert Specialist
You've lost me......
Dec 2 '09 #4
tkjensen
6 New Member
Thanks for the replay any way. Is it some other ways to make a list from the database then the premaked programs? I want my own. =)
Dec 2 '09 #5
tlhintoq
3,525 Recognized Expert Specialist
When you query the database you get a response that consists of the data matching your requirements, right? I would imagine you could display that data however you like: Make a chart of the numeric data by month... Song list by artist...
Dec 2 '09 #6
tkjensen
6 New Member
Ok. thanks for the answer. =)
Dec 2 '09 #7
sanjib65
102 New Member
If you want to show your data in the = manner, then I'd like to go for making a class of your own and setting properties there so that you can manipulate it later according your own wish.
Suppose I make a Car class like this :

Expand|Select|Wrap|Line Numbers
  1. public class Car
  2. {
  3.     //adding fields
  4.     private string _make;
  5.     private string _model;
  6.     private int _price;
  7.  
  8.     //adding properties
  9.     public string Make
  10.     {
  11.         get { return _make; }
  12.         set { _make = value; }
  13.     }
  14.     public string Model
  15.     {
  16.         get { return _model; }
  17.         set { _model = value; }
  18.     }
  19.     public int Price
  20.     {
  21.         get { return _price; }
  22.         set { _price = value; }
  23.     }
  24.     //construcor
  25.     public Car()
  26.     {
  27.         _make = "Default";
  28.         _model = "Defualt";
  29.         _price = 0;
  30.     }
  31.     //overloading
  32.     public Car(string MAKE, string MODEL, int PRICE)
  33.     {
  34.         _make = MAKE;
  35.         _model = MODEL;
  36.         _price = PRICE;
  37.     }
  38.  
Later I can add new values into the new instances of Cars by overloading the parameters. And show the values in various Label.Text....l ike this

Expand|Select|Wrap|Line Numbers
  1. protected void Button1_Click(object sender, EventArgs e)
  2.     {
  3.         Car zen1 = new Car("2002", "Maruti alto1", 60000);
  4.         Label1.Text = "Year : " + zen1.Make;
  5.         Label2.Text = "Model : " + zen1.Model;
  6.         Label3.Text = "Price : " + zen1.Price.ToString();
  7.         Label7.Text = "----------------";
  8.         Car zen2 = new Car("2008", "Zen", 70000);
  9.         Label4.Text = "Year : " + zen2.Make;
  10.         Label5.Text = "Model : " + zen2.Model;
  11.         Label6.Text = "Price : " + zen2.Price.ToString();
  12.  
  13.     }
For the simple data manipulation, I'd like to go for the XML also. I can make an XMl file of my favourite author's list, like this:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" standalone="yes"?>
  2. <dsPubs xmlns="http://www.tempuri.org/dsPubs.xsd">
  3.   <xs:schema id="dsPubs" targetNamespace="http://www.tempuri.org/dsPubs.xsd" xmlns:mstns="http://www.tempuri.org/dsPubs.xsd" xmlns="http://www.tempuri.org/dsPubs.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
  4.     <xs:element name="dsPubs" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
  5.       <xs:complexType>
  6.         <xs:choice minOccurs="0" maxOccurs="unbounded">
  7.           <xs:element name="authors">
  8.             <xs:complexType>
  9.               <xs:sequence>
  10.                 <xs:element name="au_id" type="xs:string" />
  11.                 <xs:element name="au_lname" type="xs:string" />
  12.                 <xs:element name="au_fname" type="xs:string" />
  13.                 <xs:element name="au_phone" type="xs:string" />
  14.               </xs:sequence>
  15.             </xs:complexType>
  16.           </xs:element>
  17.         </xs:choice>
  18.       </xs:complexType>
  19.       <xs:unique name="Constraint1" msdata:PrimaryKey="true">
  20.         <xs:selector xpath=".//mstns:authors" />
  21.         <xs:field xpath="mstns:au_id" />
  22.       </xs:unique>
  23.     </xs:element>
  24.   </xs:schema>
  25.   <authors>
  26.     <au_id>172-32-1176</au_id>
  27.     <au_lname>Tagore</au_lname>
  28.     <au_fname>Rabindranath</au_fname>
  29.     <au_phone>408 555-0123</au_phone>
  30.   </authors>
  31.   <authors>
  32.     <au_id>213-46-8915</au_id>
  33.     <au_lname>Cohelho</au_lname>
  34.     <au_fname>Paulo</au_fname>
  35.     <au_phone>415 555-0120</au_phone>
  36.   </authors>
  37.   <authors>
  38.     <au_id>100-01-1001</au_id>
  39.     <au_lname>Chekhov</au_lname>
  40.     <au_fname>Anton</au_fname>
  41.     <au_phone>688 123-1340</au_phone>
  42.   </authors>
  43.   <authors>
  44.     <au_id>102-02-1002</au_id>
  45.     <au_lname>Leo</au_lname>
  46.     <au_fname>Tolstoy</au_fname>
  47.     <au_phone>408 555-8569</au_phone>
  48.   </authors>
  49. </dsPubs>
  50. //as you see you can make this list longer, you can include other items here....
  51.  
Now you make a BuisObject class creating Dataset dynamically, like this:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Web;
  3. using System.Data;
  4. namespace PubsClasses
  5. {
  6.     public class AuthorClass
  7.     {
  8.         private DataSet dsAuthors = new DataSet("ds1");
  9.         private String filePath =
  10.             HttpContext.Current.Server.MapPath
  11.                 ("~/App_Data/Authors.xml");
  12.         public AuthorClass()
  13.         {
  14.             dsAuthors.ReadXml(filePath, XmlReadMode.ReadSchema);
  15.         }
  16.         public DataSet GetAuthors()
  17.         {
  18.             return dsAuthors;
  19.         }
  20.         public void InsertAuthor(String au_id, String au_lname,
  21.     String au_fname, String au_phone)
  22.         {
  23.             DataRow workRow = dsAuthors.Tables[0].NewRow();
  24.             workRow.BeginEdit();
  25.             workRow[0] = au_id;
  26.             workRow[1] = au_lname;
  27.             workRow[2] = au_fname;
  28.             workRow[3] = au_phone;
  29.             workRow.EndEdit();
  30.             dsAuthors.Tables[0].Rows.Add(workRow);
  31.             dsAuthors.WriteXml(filePath, XmlWriteMode.WriteSchema);
  32.         }
  33.     }
  34.  
  35. }
The rest of the part to show the lists by data binding with this BuisnessCobject .cs is a cake walk. There are several handy Framework Controls that you can drag and make them data-bound.

Hope this will help you.
Dec 3 '09 #8
tkjensen
6 New Member
Thanx for the reply. I'll try to get it working. =)
Dec 3 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4608
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet, including column names and row values for each column. I'm getting some strange results depending the input XML file I use. I was wondering if somebody could help me understand what is going on or point me to a good reference. The code for my program looks like this:
3
6602
by: Jeronimo Bertran | last post by:
Hi, I have an xml file that encapsulates a dataset definition within a set of tags (<dataset>)... here is an example <?xml version="1.0" encoding="utf-16"?> <dataset> <MyTable> <Field1>100</Field1> <Field2>200</Field2>
5
5412
by: Mike | last post by:
I need to expand the DataSet class by inheriting from it and adding functions that work on the data in the tables. However, since I can't upcast how can I get my base DataSet object assigned an actual DataSet? e.g. public class MyDataSet : DataSet { // can't do, no valid DataSet constructor
3
13591
by: JJ | last post by:
Hi, I need to pass a dataset to another win form along with a SqldataAdapter. I don't want to recreate the SqlDataAdapter again either. So to pass to another Win form in my windows form app, do I create the procedure to pass by ref? Which means I don't need to add ByRef because it is defaulted by ref, correct? And in the constructor of the win form that gets created. I need to add in parameters a DataSet and SqlDataAdapter correct? What...
5
3703
by: Jason | last post by:
I am having problems understanding how to access a datasource only once, fill a single dataset, and then reference that dataset multiple times through different user controls(ascx) found on the same page. My main page(aspx) contains multiple user controls. The main page also contains a publicly declared dataset. At the first instance of needing data I call (from an ascx) a function that fills the dataset and then returns it to the...
2
3385
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code that does a query and returns a data reader and then appends the data to a dataset that is built in the Page_Load code in the if(!isPostBack) block. When I try to add a row in the button click event code I get an error saying that "Object reference not set to an instance of an object". I'm...
15
2249
by: JIM.H. | last post by:
Hello, Can I send a dataset as a parameter into stored procedure and import data to a table in the stored procedure? Thanks, Jim.
16
2489
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill it with incremental values e.g. if the tables looks like this: 23 56
22
25604
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to compile. <WebMethod()> _ Public Function VerifySku(ByVal skus As XmlDataDocument) As DataSet Test program : Dim cartSet As DataSet cartSet = ws.VerifySku(cartSet)
1
2539
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then can re-run the report and get fresh data. now, they would like to be able to compare the fresh data to the stored data, getting a break-down of added/deleted/changed rows. on the surface, this sounded plausible -- by deserializing the stored
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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...
1
7413
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...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.