How to create a data set
Create your dataset and table adapter1. Create your frame 2. Drop a Data Grid View control3. Create a Dataset (xsd) File.4. Open your xsd file. 5. Drag the table that you want to work with from the server explorer. Your table and table adapter will be created.If
you click the Table Adapter and check its properties you will see that
the select, insert, update and delete command are automatically
generated....
Thursday, April 25, 2013
Tuesday, April 16, 2013
Filter Data in DataSet using C#
How to filter Data in DataSet
DataView Class is used to filter and sorting of data in Data Set
Here I m giving an example of how we can filter and sort data in data set.
DataView: A DataView is used to create different views of the data stored in a DataSet of DataTable
I am using following sqlserver database table in my example. Create a table using this script
CREATE TABLE tbemp
(
eno int NULL ,
ename varchar (50) NULL,
eadd varchar (50) NULL,
...
Looping through DataSet in C#
To loop through DataTable, try this
if (datatable1 !=null)
{
foreach (DataRow dr i datatable1.Rows)
{
string text1 = dr["Column1Name"].ToString();
string text2 = dr["Column1Name"].ToString();
// and so on
//You can also set your Literal cotrol as
}...
Dataset Data set Dataset in C-sharp Dataset C-Sharp example Dataset in .net
DataSet
is a collection of DataTables.
We use the DataSet type to store many DataTables in a single collection.
Conceptually, the DataSet acts as a set of DataTable instances.
This simplifies programs that use many DataTables.
DataTable
Create
To effectively use the DataSet, you will need to have some DataTables handy.
In this program, we create two DataTables.
One stores two rows of patient information.
And the second stores two...
Convert DataSet to DataTable
A DataSet already contains DataTables. You can just use:
DataTable firstTable = dataSet.Tables[0];
or by name:
DataTable customerTable = dataSet.Tables["Customer"];
Note that you should have using statements for your SQL code, to ensure the connection is disposed properly:
using (SqlConnection conn = ...)
{
// Code here...
...
Sunday, April 7, 2013
dataset to excel c#
here is the solution for that.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using Microsoft.Office.Interop;
private void btn_ETexcel_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.ApplicationClass ExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
ExcelApp.Application.Workbooks.Add(Type.Missing);
ExcelApp.Columns.ColumnWidth...