add a class from solution explorer
and then paste this code
to clear all textbox values in winforms
--------------------------------------------------
vb.net
------------------
Public Sub ClearForm(ByVal Frm As Form, Optional ByVal All As Boolean = True)
Dim Ctr As Control
If All Then
For Each Ctr In Frm.Controls
If TypeOf Ctr Is TextBox Then
Ctr.Text = ""
End If
Next
End If
End Sub
--------------------------------------------------
IN FORM1
Dim s As New Class1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
s.ClearForm(Me)
End Sub
-------------------------------------------------
URL
http://www.devx.com/tips/Tip/30880
------------------------------------------------
C#
-----------------------------------------------
add a class from solution explorer
and then paste this code
using System.Windows.Forms;
public void ClrCrlVal(System.Windows.Forms.Control Container)
{
try
{
foreach (Control ctrl in Container.Controls)
{
if (ctrl.GetType() == typeof(TextBox))
((TextBox)ctrl).Text = "";
if (ctrl.GetType() == typeof(ComboBox))
((ComboBox)ctrl).SelectedIndex = -1;
if (ctrl.GetType() == typeof(CheckBox))
((CheckBox)ctrl).Checked = false;
if (ctrl.GetType() == typeof(Label))
((Label)ctrl).Text = "";
if (ctrl.GetType() == typeof(DateTimePicker))
((DateTimePicker)ctrl).Text = "";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
-----------------------------------------------------
IN FORM
private void button1_Click(object sender, EventArgs e)
{
Class1 c = new Class1();
c.ClrCrlVal(this);
}
-----------------------------------------------
Hunt
Tuesday, April 27, 2010
Saturday, April 24, 2010
DIFFERENCE BETWEEN USER CONTROL AND CUSTOM CONTROL
Difference between user controls and custom controls in .net (vb, c# net with asp.net)
User controls:
It is newly concept in .net it same like as inheritance concept in oops
In asp.net the base class is system.web.ui.page object
When ever creating user control that will be converting as a class, and this class become
Subclasses of System.web.ui.page class at compile time
User control extension with .ascx
Let us see program how build (at end I will mention difference between user control and
Custom control)
Custom control:
Creating user controls, which are essentially reusable small web pages,
You can also create your own compiled custom controls.
There are three ways to create custom controls:
1) Create a derived custom control by deriving from an existing control.
2) Create a composite control by grouping existing controls together into a new compiled control.
3) Create a full custom control by deriving from System.Web.UI.WebControls.WebControl
Composite controls are most similar to user controls. The key difference is that composite
Controls are compiled into a DLL and used as you would any server control.
Let us programmatically that will help how to build:
Iam explaining on simple example:
Take notepad example:
Imports System.ComponentModel
Imports System.Web.UI
("<{0}: WebCustomControl1 runat=server>")>
Public Class WebCustomControl1
Inherits System.Web.UI.WebControls.WebControl
Dim text As String
Property [Text]() As String
Get
Return text
End Get
Set(ByVal Value As String)
text = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write([Text])
End Sub
End Class
Now compile then it generate one dll
Now open IDE language is vb.net with asp.net
Just write in html of .vb page
<% @ Register Tag prefix=”raghu” namespace=”chinni” assembly= “WebControlLibrary1” %>
Now create instance
Under
<form>
<raghu:chinni ID=”tatcis” Text=”this is placid man”/><form>
Now press F5
U gets output as
this is placid man
Let us see differences
User control
1) Reusability web page
2) We can’t add to toolbox
3) Just drag and drop from solution explorer to page (aspx)
4) U can register user control to. Aspx page by Register tag
5) A separate copy of the control is required in each application
6) Good for static layout
7) Easier to create
8)Not complied into DLL
9) Here page (user page) can be converted as control then
We can use as control in aspx
Custom controls
1) Reusability of control (or extend functionalities of existing control)
2) We can add toolbox
3) Just drag and drop from toolbox
4) U can register user control to. Aspx page by Register tag
5) A single copy of the control is required in each application
6) Good for dynamics layout
7) Hard to create
8) Compiled in to dll
===============================
URL
http://www.dotnetspider.com/resources/1914-Difference-Between-usercontrol-custom-control.aspx
http://www.dotnetfunda.com/interview/exam379-difference-between-custom-control-and-user-control-.aspx
http://jalpesh.blogspot.com/2009/05/what-is-difference-between-user-control.html
--------------------------------------------
DIFFERENCE BETWEEN MACHINE.CONFIG AND WEB.CONFIG
----------------------------------------------------
Web.Config..
1.In web.config we can store,
Database Connection
Session State
Error handling
Security
Machine.Config..
1.In machine.config we can store,
Connection strings
Membership
Role Manager
Profile
HTTP Handlers
For More Details..
http://www.geekinterview.com/question_details/21032
http://www.geekinterview.com/question_details/39708
http://www.allinterview.com/showanswers/56550.html
------------------------------------------------------------
User controls:
It is newly concept in .net it same like as inheritance concept in oops
In asp.net the base class is system.web.ui.page object
When ever creating user control that will be converting as a class, and this class become
Subclasses of System.web.ui.page class at compile time
User control extension with .ascx
Let us see program how build (at end I will mention difference between user control and
Custom control)
Custom control:
Creating user controls, which are essentially reusable small web pages,
You can also create your own compiled custom controls.
There are three ways to create custom controls:
1) Create a derived custom control by deriving from an existing control.
2) Create a composite control by grouping existing controls together into a new compiled control.
3) Create a full custom control by deriving from System.Web.UI.WebControls.WebControl
Composite controls are most similar to user controls. The key difference is that composite
Controls are compiled into a DLL and used as you would any server control.
Let us programmatically that will help how to build:
Iam explaining on simple example:
Take notepad example:
Imports System.ComponentModel
Imports System.Web.UI
("<{0}: WebCustomControl1 runat=server>")>
Public Class WebCustomControl1
Inherits System.Web.UI.WebControls.WebControl
Dim text As String
Property [Text]() As String
Get
Return text
End Get
Set(ByVal Value As String)
text = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write([Text])
End Sub
End Class
Now compile then it generate one dll
Now open IDE language is vb.net with asp.net
Just write in html of .vb page
<% @ Register Tag prefix=”raghu” namespace=”chinni” assembly= “WebControlLibrary1” %>
Now create instance
Under
<form>
<raghu:chinni ID=”tatcis” Text=”this is placid man”/><form>
Now press F5
U gets output as
this is placid man
Let us see differences
User control
1) Reusability web page
2) We can’t add to toolbox
3) Just drag and drop from solution explorer to page (aspx)
4) U can register user control to. Aspx page by Register tag
5) A separate copy of the control is required in each application
6) Good for static layout
7) Easier to create
8)Not complied into DLL
9) Here page (user page) can be converted as control then
We can use as control in aspx
Custom controls
1) Reusability of control (or extend functionalities of existing control)
2) We can add toolbox
3) Just drag and drop from toolbox
4) U can register user control to. Aspx page by Register tag
5) A single copy of the control is required in each application
6) Good for dynamics layout
7) Hard to create
8) Compiled in to dll
===============================
URL
http://www.dotnetspider.com/resources/1914-Difference-Between-usercontrol-custom-control.aspx
http://www.dotnetfunda.com/interview/exam379-difference-between-custom-control-and-user-control-.aspx
http://jalpesh.blogspot.com/2009/05/what-is-difference-between-user-control.html
--------------------------------------------
DIFFERENCE BETWEEN MACHINE.CONFIG AND WEB.CONFIG
----------------------------------------------------
Web.Config..
1.In web.config we can store,
Database Connection
Session State
Error handling
Security
Machine.Config..
1.In machine.config we can store,
Connection strings
Membership
Role Manager
Profile
HTTP Handlers
For More Details..
http://www.geekinterview.com/question_details/21032
http://www.geekinterview.com/question_details/39708
http://www.allinterview.com/showanswers/56550.html
------------------------------------------------------------
Saturday, February 27, 2010
CRYSTAL REPORT CONCEPTS UPDATED for WINDOWS APPLICATION
*********************************************************************************
Most valuable method No need giving local path:
*********************************************************************************
through dataset u can achieve this:
1) To add crystalreportviewer in windows form
2)To Add the following name space
using CrystalDecisions.CrystalReports.Engine;
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("provider=sqloledb;server=.;database=northwind;integrated security=sspi");
con.Open();
OleDbDataAdapter ada = new OleDbDataAdapter("SELECT * FROM EMPLOYEES", con);
DataSet ds = new DataSet();
ada.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count-1; i++)
{
comboBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("provider=sqloledb;server=.;database=northwind;integrated security=sspi");
con.Open();
OleDbDataAdapter ada = new OleDbDataAdapter("SELECT * FROM EMPLOYEES WHERE EMPLOYEEID='" + comboBox1.Text.ToString() + "' ", con);
DataSet ds = new DataSet();
ada.Fill(ds);
CrystalReport4 cra = new CrystalReport4();
cra.SetParameterValue("@id", ds.Tables[0].Rows[0][0].ToString());
cra.SetParameterValue("@name", ds.Tables[0].Rows[0][1].ToString());
cra.SetParameterValue("@title", ds.Tables[0].Rows[0][2].ToString());
crystalReportViewer1.ReportSource = cra;
}
3)In crystalrepor.rpt do the following things
i)Select Blank report
ii) In the field explorer select parameter
iii)add new parameter according to setparamervalues("@id",dr[0].ToString()).
================================================================
************************************************************
Best Way To show crystal report in windows application
*************************************************************
1) To add crystalreportviewer in windows form
2)To Add the following name space
using CrystalDecisions.CrystalReports.Engine;
To Load Id values in combobox with help of following code:
private void Form2_Load(object sender, EventArgs e)
{
OleDbCommand cmd = new OleDbCommand("SELECT EMPLOYEEID FROM EMPLOYEES", con);
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr[0].ToString());
}
dr.Close();
con.Close();
}
To add following code in button event
private void button1_Click(object sender, EventArgs e)
{
ReportDocument rep = new ReportDocument();
rep.Load ("D:\\VIVEK\\Practise\\crystalreport\\crystalreport\\CrystalReport3.rpt");
con.Open();
cmd1 =new OleDbCommand ("SELECT * FROM EMPLOYEES where EMPLOYEEID='"+comboBox1 .Text +"'", con);
dr=cmd1.ExecuteReader ();
if (dr.Read ())
{
rep.SetParameterValue ("@id",dr[0].ToString());
rep.SetParameterValue("@name", dr[1].ToString());
rep.SetParameterValue("@title", dr[2].ToString());
}
dr.Close();
con.Close();
crystalReportViewer1.ReportSource = rep;
}
3)In crystalrepor.rpt do the following things
i)Select Blank report
ii) In the field explorer select parameter
iii)add new parameter according to setparamervalues("@id",dr[0].ToString()).
Now u can get desired values according to ur selection
================================================
CRYSTAL REPORT USING DATASET
==============================================
WINDOWS APPLICATION
==============================
- ADD A DATASET
- IN THAT DATASET RIGHT CLICK AND CHOOSE DATA TABLE.
- IN THAT DATATALE RIGHT CLICK AND ADD COLUMN(GIVE DATABASE TABLE COLUMN NAMES AS DATATABLE COLUMN NAME) ANT THEN SAVE
-ADD CRYSTAL REPORT AND CHOOSE AS BLANK REPORT
-THEN IN THAT CRYSTAL REPORT GOTO FILED EXPLORER AND THEN RIGHT CLIK IN DATABASE FIELDS->
CHOOSE DATABASE EXPERT
- THEN A WIZARD IS COME THEN GOTO PROJECT DATA->ADO.NET DATASETS->CHOOSE OUR DATATABLE->CLICK >> -> CLICK FINISH
-------------------------
IN FORM
-ADD A COMBOBOX
-ADD A CRYSTAL REPORT VIEWER
-ADD using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
SqlConnection con = new SqlConnection("server=.;database=sam;integrated security=true");
SqlCommand cmd;
SqlDataReader dr;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
private void Form1_Load(object sender, EventArgs e)
{
cmd = new SqlCommand("select distinct(idd) from a", con);
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr[0].ToString());
}
dr.Close();
con.Close();
}
============================================
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
da = new SqlDataAdapter("select * from a where idd='" + comboBox1.SelectedItem.ToString() + "'", con);
ds.Clear();
da.Fill(ds, "dt");//DT IS DATATABLE NAME IN DATASET
CrystalReport1 c = new CrystalReport1();
c.SetDataSource(ds);
crystalReportViewer1.ReportSource = c;
}
====================================
WEB APPLICATION
=========================
ADD A DATASET
- IN THAT DATASET RIGHT CLICK AND CHOOSE DATA TABLE.
- IN THAT DATATALE RIGHT CLICK AND ADD COLUMN(GIVE DATABASE TABLE COLUMN NAMES AS DATATABLE COLUMN NAME) ANT THEN SAVE
-ADD CRYSTAL REPORT AND CHOOSE AS BLANK REPORT
-THEN IN THAT CRYSTAL REPORT GOTO FILED EXPLORER AND THEN RIGHT CLIK IN DATABASE FIELDS->
CHOOSE DATABASE EXPERT
- THEN A WIZARD IS COME THEN GOTO PROJECT DATA->ADO.NET DATASETS->CHOOSE OUR DATATABLE->CLICK >> -> CLICK FINISH
===================================
IN PAGE
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using System.Data.SqlClient;
SqlConnection con = new SqlConnection("server=.;database=sam;integrated security=true");
SqlCommand cmd;
SqlDataReader dr;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
protected void DropDownList1_Init(object sender, EventArgs e)
{
cmd = new SqlCommand("select distinct(idd) from a", con);
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
DropDownList1.Items.Add(dr[0].ToString());
}
dr.Close();
con.Close();
}
====================================
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
da = new SqlDataAdapter("select * from a where idd='" + DropDownList1.SelectedItem.ToString() + "'", con);
ds.Clear();
da.Fill(ds, "dt");
ReportDocument r = new ReportDocument();
r.Load(Server.MapPath("CrystalReport.rpt"));
r.SetDataSource(ds);
CrystalReportViewer1.ReportSource = r;
}
====================================
URLS
http://www.beansoftware.com/ASP.NET-Tutorials/Using-Crystal-Reports.aspx
http://forums.asp.net/76.aspx
http://www.highoncoding.com/Articles/550_Creating_Crystal_Report_in_ASP_NET.aspx
http://www.c-sharpcorner.com/UploadFile/rsubhajit/CrystalReportwithDataSet03012006060655AM/CrystalReportwithDataSet.aspx
http://aspalliance.com/776
http://www.aspfree.com/c/a/ASP.NET/Working-with-ADONET-Datasets-and-NET-Objects-using-Crystal-Reports-and-ASP-NET-2-0/1/
http://www.codeproject.com/KB/aspnet/crystal_report.aspx
Most valuable method No need giving local path:
*********************************************************************************
through dataset u can achieve this:
1) To add crystalreportviewer in windows form
2)To Add the following name space
using CrystalDecisions.CrystalReports.Engine;
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("provider=sqloledb;server=.;database=northwind;integrated security=sspi");
con.Open();
OleDbDataAdapter ada = new OleDbDataAdapter("SELECT * FROM EMPLOYEES", con);
DataSet ds = new DataSet();
ada.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count-1; i++)
{
comboBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("provider=sqloledb;server=.;database=northwind;integrated security=sspi");
con.Open();
OleDbDataAdapter ada = new OleDbDataAdapter("SELECT * FROM EMPLOYEES WHERE EMPLOYEEID='" + comboBox1.Text.ToString() + "' ", con);
DataSet ds = new DataSet();
ada.Fill(ds);
CrystalReport4 cra = new CrystalReport4();
cra.SetParameterValue("@id", ds.Tables[0].Rows[0][0].ToString());
cra.SetParameterValue("@name", ds.Tables[0].Rows[0][1].ToString());
cra.SetParameterValue("@title", ds.Tables[0].Rows[0][2].ToString());
crystalReportViewer1.ReportSource = cra;
}
3)In crystalrepor.rpt do the following things
i)Select Blank report
ii) In the field explorer select parameter
iii)add new parameter according to setparamervalues("@id",dr[0].ToString()).
================================================================
************************************************************
Best Way To show crystal report in windows application
*************************************************************
1) To add crystalreportviewer in windows form
2)To Add the following name space
using CrystalDecisions.CrystalReports.Engine;
To Load Id values in combobox with help of following code:
private void Form2_Load(object sender, EventArgs e)
{
OleDbCommand cmd = new OleDbCommand("SELECT EMPLOYEEID FROM EMPLOYEES", con);
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr[0].ToString());
}
dr.Close();
con.Close();
}
To add following code in button event
private void button1_Click(object sender, EventArgs e)
{
ReportDocument rep = new ReportDocument();
rep.Load ("D:\\VIVEK\\Practise\\crystalreport\\crystalreport\\CrystalReport3.rpt");
con.Open();
cmd1 =new OleDbCommand ("SELECT * FROM EMPLOYEES where EMPLOYEEID='"+comboBox1 .Text +"'", con);
dr=cmd1.ExecuteReader ();
if (dr.Read ())
{
rep.SetParameterValue ("@id",dr[0].ToString());
rep.SetParameterValue("@name", dr[1].ToString());
rep.SetParameterValue("@title", dr[2].ToString());
}
dr.Close();
con.Close();
crystalReportViewer1.ReportSource = rep;
}
3)In crystalrepor.rpt do the following things
i)Select Blank report
ii) In the field explorer select parameter
iii)add new parameter according to setparamervalues("@id",dr[0].ToString()).
Now u can get desired values according to ur selection
================================================
CRYSTAL REPORT USING DATASET
==============================================
WINDOWS APPLICATION
==============================
- ADD A DATASET
- IN THAT DATASET RIGHT CLICK AND CHOOSE DATA TABLE.
- IN THAT DATATALE RIGHT CLICK AND ADD COLUMN(GIVE DATABASE TABLE COLUMN NAMES AS DATATABLE COLUMN NAME) ANT THEN SAVE
-ADD CRYSTAL REPORT AND CHOOSE AS BLANK REPORT
-THEN IN THAT CRYSTAL REPORT GOTO FILED EXPLORER AND THEN RIGHT CLIK IN DATABASE FIELDS->
CHOOSE DATABASE EXPERT
- THEN A WIZARD IS COME THEN GOTO PROJECT DATA->ADO.NET DATASETS->CHOOSE OUR DATATABLE->CLICK >> -> CLICK FINISH
-------------------------
IN FORM
-ADD A COMBOBOX
-ADD A CRYSTAL REPORT VIEWER
-ADD using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
SqlConnection con = new SqlConnection("server=.;database=sam;integrated security=true");
SqlCommand cmd;
SqlDataReader dr;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
private void Form1_Load(object sender, EventArgs e)
{
cmd = new SqlCommand("select distinct(idd) from a", con);
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr[0].ToString());
}
dr.Close();
con.Close();
}
============================================
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
da = new SqlDataAdapter("select * from a where idd='" + comboBox1.SelectedItem.ToString() + "'", con);
ds.Clear();
da.Fill(ds, "dt");//DT IS DATATABLE NAME IN DATASET
CrystalReport1 c = new CrystalReport1();
c.SetDataSource(ds);
crystalReportViewer1.ReportSource = c;
}
====================================
WEB APPLICATION
=========================
ADD A DATASET
- IN THAT DATASET RIGHT CLICK AND CHOOSE DATA TABLE.
- IN THAT DATATALE RIGHT CLICK AND ADD COLUMN(GIVE DATABASE TABLE COLUMN NAMES AS DATATABLE COLUMN NAME) ANT THEN SAVE
-ADD CRYSTAL REPORT AND CHOOSE AS BLANK REPORT
-THEN IN THAT CRYSTAL REPORT GOTO FILED EXPLORER AND THEN RIGHT CLIK IN DATABASE FIELDS->
CHOOSE DATABASE EXPERT
- THEN A WIZARD IS COME THEN GOTO PROJECT DATA->ADO.NET DATASETS->CHOOSE OUR DATATABLE->CLICK >> -> CLICK FINISH
===================================
IN PAGE
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using System.Data.SqlClient;
SqlConnection con = new SqlConnection("server=.;database=sam;integrated security=true");
SqlCommand cmd;
SqlDataReader dr;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
protected void DropDownList1_Init(object sender, EventArgs e)
{
cmd = new SqlCommand("select distinct(idd) from a", con);
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
DropDownList1.Items.Add(dr[0].ToString());
}
dr.Close();
con.Close();
}
====================================
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
da = new SqlDataAdapter("select * from a where idd='" + DropDownList1.SelectedItem.ToString() + "'", con);
ds.Clear();
da.Fill(ds, "dt");
ReportDocument r = new ReportDocument();
r.Load(Server.MapPath("CrystalReport.rpt"));
r.SetDataSource(ds);
CrystalReportViewer1.ReportSource = r;
}
====================================
URLS
http://www.beansoftware.com/ASP.NET-Tutorials/Using-Crystal-Reports.aspx
http://forums.asp.net/76.aspx
http://www.highoncoding.com/Articles/550_Creating_Crystal_Report_in_ASP_NET.aspx
http://www.c-sharpcorner.com/UploadFile/rsubhajit/CrystalReportwithDataSet03012006060655AM/CrystalReportwithDataSet.aspx
http://aspalliance.com/776
http://www.aspfree.com/c/a/ASP.NET/Working-with-ADONET-Datasets-and-NET-Objects-using-Crystal-Reports-and-ASP-NET-2-0/1/
http://www.codeproject.com/KB/aspnet/crystal_report.aspx
Tuesday, February 16, 2010
DIFFERNECES..
DIFFERENCE BETWEEN DATAREADER AND DATASET
===================================================
Answer:
DataReader
===========
DataReader is like a forward only recordset. It fetches one row at a time so very less network cost compare to DataSet(Fethces all the rows at a time). DataReader is readonly so we can't do any transaction on them. DataReader will be the best choice where we need to show the data to the user which requires no transaction. As DataReader is forward only so we can't fetch data randomly. .NET Data Providers optimizes the datareader to handle huge amount of data.
DataSet
=======
DataSet is an in memory representation of a collection of Database objects including tables of a relational database schemas.
DataSet is always a bulky object that requires a lot of memory space compare to DataReader. We can say that the DataSet is a small database because it stores the schema and data in the application memory area. DataSet fetches all data from the datasource at a time to its memory area. So we can traverse through the object to get the required data like querying database.
URL:
http://www.dotnetfunda.com/interview/exam13-difference-between-dataset-and-datareader.aspx
A DataReader works in a connected environment, whereas DataSet works in a disconnected environment.
A DataReader object represents a forward only, read only access to data from a source. It implements IDataReader & IDataRecord interfaces. For example, The SQLDataReader class can read rows from tables in a SQL Server data source. It is returned by the ExecuteReader method of the SQLCommand class, typically as a result of a SQL Select statement. The DataReader class' HasRows property can be called to determine whether the DataReader retrieved any rows from the source. This can be used before using the Read method to check whether any data has been retrieved.
Example
Dim objCmd as New SqlCommand("Select * from t_Employees", objCon)
objCon.Open()
Dim objReader as SqlDataReader
objReader = objCom.ExecuteReader(CommandBehavior.CloseConnection)
If objReader.HasRows = True then
Do While objReader.Read()
ListBox1.Items.Add(objReader.GetString(0) & vbTab & objReader.GetInt16(1))
Loop
End If
objReader.Close()
(NOTE: XmlReader object is used for Forward only Read only access of XML).
A DataSet represents an in-memory cache of data consisting of any number of inter-related DataTable objects. A DataTable object represents a tabular block of in-memory data. Further, a DataRow represents a single row of a DataTable object. A Dataset is like a mini-database engine, but its data is stored in the memory. To query the data in a DataSet, we can use a DataView object.
Example
Dim objCon as SqlConnection = New SqlConnection("server=(local);database=NameOfYourDb;user id=sa; password=;)
Dim da as New SqlDataAdapter
Dim ds as DataSet = New DataSet
da.SelectCommand.Connection = objCon 'The Data Adapter manages on its own, opening & closing of connection object
da.SelectCommand.CommandText = "Select * from t_SomeTable"
da.Fill(ds,"YourTableName")
Suppose you want to bind the data in this dataset to a gridview
Gridview1.DataSource = ds
Gridview1.DataMember = "YourTableName"
Gridview1.Databind()
URL
http://www.dotnetuncle.com/Difference/111_DataReader_Dataset.aspx
================================================================================
Difference between Repeater, Datalist and GridView Control
URL:http://www.dotnetspider.com/resources/29917-Difference-between-Repeater-Datalist.aspx
In ASP .NET basically there are 3 kinds of the Data Presentation Controls.
1. GridView (or DataGrid) control
2. DataList control
3. Repeater control
When we talk about usage of one Data Presentation Controls then many of us get confused about choosing one. When you need to use one of the data Presentation Control then You have to see what kind of behavior you need in your Data Display.
1. Do you want to show Data in many Pages or in one page?
2. Do you have to Display more then one column in a Row ?
3. Do you want to have a Row repeating Possibility?
4. Will users be able to update, Insert and delete the Data?
Features of a GridView
•Displays data as a table
•Control over
–Alternate item
–Header
–Footer
–Colors, font, borders, etc.
–Paging
•Updateable
•Item as row
Features of Repeater
•List format
•No default output
•More control
•More complexity
•Item as row
•Not updateable
Features of DataList
•Directional rendering
•Good for columns
•Item as cell
•Alternate item
•Updateable
==========================================================
DIFFERNCE BETWEEN DATATABLE AND DATASET
A DataSet is an in memory representation of data,It containing one or more DataTables.
A DataTable is an in-memory representation of data, typically retrieved from a database or XML source.
A Dataset is like a Container for Datatables because every dataset has a datatable contained inside it and a Datatable is like a table you have in SQL and a Dataset its like a Database that contain table(Datatable)
URL
http://www.dotnetfunda.com/forums/thread615-what-is-the-difference-between-datatable-and-dataset.aspx
==============================================================================
===================================================
Answer:
DataReader
===========
DataReader is like a forward only recordset. It fetches one row at a time so very less network cost compare to DataSet(Fethces all the rows at a time). DataReader is readonly so we can't do any transaction on them. DataReader will be the best choice where we need to show the data to the user which requires no transaction. As DataReader is forward only so we can't fetch data randomly. .NET Data Providers optimizes the datareader to handle huge amount of data.
DataSet
=======
DataSet is an in memory representation of a collection of Database objects including tables of a relational database schemas.
DataSet is always a bulky object that requires a lot of memory space compare to DataReader. We can say that the DataSet is a small database because it stores the schema and data in the application memory area. DataSet fetches all data from the datasource at a time to its memory area. So we can traverse through the object to get the required data like querying database.
URL:
http://www.dotnetfunda.com/interview/exam13-difference-between-dataset-and-datareader.aspx
A DataReader works in a connected environment, whereas DataSet works in a disconnected environment.
A DataReader object represents a forward only, read only access to data from a source. It implements IDataReader & IDataRecord interfaces. For example, The SQLDataReader class can read rows from tables in a SQL Server data source. It is returned by the ExecuteReader method of the SQLCommand class, typically as a result of a SQL Select statement. The DataReader class' HasRows property can be called to determine whether the DataReader retrieved any rows from the source. This can be used before using the Read method to check whether any data has been retrieved.
Example
Dim objCmd as New SqlCommand("Select * from t_Employees", objCon)
objCon.Open()
Dim objReader as SqlDataReader
objReader = objCom.ExecuteReader(CommandBehavior.CloseConnection)
If objReader.HasRows = True then
Do While objReader.Read()
ListBox1.Items.Add(objReader.GetString(0) & vbTab & objReader.GetInt16(1))
Loop
End If
objReader.Close()
(NOTE: XmlReader object is used for Forward only Read only access of XML).
A DataSet represents an in-memory cache of data consisting of any number of inter-related DataTable objects. A DataTable object represents a tabular block of in-memory data. Further, a DataRow represents a single row of a DataTable object. A Dataset is like a mini-database engine, but its data is stored in the memory. To query the data in a DataSet, we can use a DataView object.
Example
Dim objCon as SqlConnection = New SqlConnection("server=(local);database=NameOfYourDb;user id=sa; password=;)
Dim da as New SqlDataAdapter
Dim ds as DataSet = New DataSet
da.SelectCommand.Connection = objCon 'The Data Adapter manages on its own, opening & closing of connection object
da.SelectCommand.CommandText = "Select * from t_SomeTable"
da.Fill(ds,"YourTableName")
Suppose you want to bind the data in this dataset to a gridview
Gridview1.DataSource = ds
Gridview1.DataMember = "YourTableName"
Gridview1.Databind()
URL
http://www.dotnetuncle.com/Difference/111_DataReader_Dataset.aspx
================================================================================
Difference between Repeater, Datalist and GridView Control
URL:http://www.dotnetspider.com/resources/29917-Difference-between-Repeater-Datalist.aspx
In ASP .NET basically there are 3 kinds of the Data Presentation Controls.
1. GridView (or DataGrid) control
2. DataList control
3. Repeater control
When we talk about usage of one Data Presentation Controls then many of us get confused about choosing one. When you need to use one of the data Presentation Control then You have to see what kind of behavior you need in your Data Display.
1. Do you want to show Data in many Pages or in one page?
2. Do you have to Display more then one column in a Row ?
3. Do you want to have a Row repeating Possibility?
4. Will users be able to update, Insert and delete the Data?
Features of a GridView
•Displays data as a table
•Control over
–Alternate item
–Header
–Footer
–Colors, font, borders, etc.
–Paging
•Updateable
•Item as row
Features of Repeater
•List format
•No default output
•More control
•More complexity
•Item as row
•Not updateable
Features of DataList
•Directional rendering
•Good for columns
•Item as cell
•Alternate item
•Updateable
==========================================================
DIFFERNCE BETWEEN DATATABLE AND DATASET
A DataSet is an in memory representation of data,It containing one or more DataTables.
A DataTable is an in-memory representation of data, typically retrieved from a database or XML source.
A Dataset is like a Container for Datatables because every dataset has a datatable contained inside it and a Datatable is like a table you have in SQL and a Dataset its like a Database that contain table(Datatable)
URL
http://www.dotnetfunda.com/forums/thread615-what-is-the-difference-between-datatable-and-dataset.aspx
==============================================================================
Saturday, January 23, 2010
FOLDER CREATION PRGRAMMATICALLY USING C#
URL
====================
http://www.sarampalis.org/articles/dotnet/dotnet0002.shtml
http://search.code-head.com/F-Share-folder-files-and-setting-permission-on-C-over-the-internet-1404158
--http://www.codeproject.com/KB/system/Share-Folder-c_.aspx
http://www.redmondpie.com/applying-permissions-on-any-windows-folder-using-c/
====================
/*using System;
using System.IO;
using System.Net;
using System.Management;*/
try
{
// create a directory
Directory.CreateDirectory(@"C:\MyTestShare");
// Create a ManagementClass object
ManagementClass managementClass = new ManagementClass("Win32_Share");
// Create ManagementBaseObjects for in and out parameters
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
// Set the input parameters
inParams["Description"] = "My Files Share";
inParams["Name"] = "My Files Share";
inParams["Path"] = @"C:\MyTestShare";
inParams["Type"] = 0x0; // Disk Drive
// Invoke the method on the ManagementClass object
outParams = managementClass.InvokeMethod("Create", inParams, null);
// Check to see if the method invocation was successful
if((uint)(outParams.Properties["ReturnValue"].Value) != 0)
{
throw new Exception("Unable to share directory.");
}
}
catch(Exception e)
{
return e.Message;
}
=============================================================
TO CREATE A FOLDER ONLY
===============================================================
System.IO.Directory.CreateDirectory(@"F:\MyFirstDir");
==============================================================
====================
http://www.sarampalis.org/articles/dotnet/dotnet0002.shtml
http://search.code-head.com/F-Share-folder-files-and-setting-permission-on-C-over-the-internet-1404158
--http://www.codeproject.com/KB/system/Share-Folder-c_.aspx
http://www.redmondpie.com/applying-permissions-on-any-windows-folder-using-c/
====================
/*using System;
using System.IO;
using System.Net;
using System.Management;*/
try
{
// create a directory
Directory.CreateDirectory(@"C:\MyTestShare");
// Create a ManagementClass object
ManagementClass managementClass = new ManagementClass("Win32_Share");
// Create ManagementBaseObjects for in and out parameters
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
// Set the input parameters
inParams["Description"] = "My Files Share";
inParams["Name"] = "My Files Share";
inParams["Path"] = @"C:\MyTestShare";
inParams["Type"] = 0x0; // Disk Drive
// Invoke the method on the ManagementClass object
outParams = managementClass.InvokeMethod("Create", inParams, null);
// Check to see if the method invocation was successful
if((uint)(outParams.Properties["ReturnValue"].Value) != 0)
{
throw new Exception("Unable to share directory.");
}
}
catch(Exception e)
{
return e.Message;
}
=============================================================
TO CREATE A FOLDER ONLY
===============================================================
System.IO.Directory.CreateDirectory(@"F:\MyFirstDir");
==============================================================
Wednesday, December 30, 2009
datalist paging
Datalist asp.net c# example
In SQL-Server
create table emp(empid int,empname varchar(50),empdesc varchar(500))
datalist.aspx.cs
<asp:DataList Width="43%" ID="DataList1" runat="server" onitemdatabound="DataList1_ItemDataBound">;
<ItemTemplate>
<table width="50%">
<tr bgcolor="silver">
<td width="50%">
<asp:Label ID="lbl_1" runat="server" Text="first"></asp:Label>
</td>
<td width="50%">
<asp:Label ID="lbl_2" runat="server" Text="second"></asp:Label>
</td>
</tr>
<tr bgcolor="lime">
<td width="100%" colspan="2">
<asp:TextBox ID="txt_1" TextMode="multiLine" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
datalist.cs
SqlDataAdapter da;
DataTable dt= new DataTable();
int counter = 0;
in pageload event call this bind() method:
bind()
{
SqlConnection con = new SqlConnection("server=.;database=demo;integrated security=true;");
con.Open();
da = new SqlDataAdapter("select * from emp", con);
da.Fill(dt);
con.Close();
DataList1.DataSource = dt;
DataList1.DataBind();
}
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
Label lbl1 = (Label)e.Item.FindControl("lbl_1");
lbl1.Text = dt.Rows[counter][0].ToString();
Label lbl2 = (Label)e.Item.FindControl("lbl_2");
lbl2.Text = dt.Rows[counter][1].ToString();
TextBox txt = (TextBox)e.Item.FindControl("txt_1");
txt.Text = dt.Rows[counter][2].ToString();
counter++;
}
=============================
URL
=============================
http://aspalliance.com/157_Paging_in_DataList
http://www.c-sharpcorner.com/UploadFile/rizwan328/DataListCustomPaging01112009021450AM/DataListCustomPaging.aspx
http://www.aspdotnetcodes.com/DataList_Dynamic_Paging_PagedDataSource.aspx
======================================
PAGING IN DATALIST
==========================================
PLACE A DATALIST CONTROL AND INSIDE DATALIST PLACE TWO LABELS AS ITEM TEMPLATE
PLACE TWO LINK BUTTONS
DEFAULT.ASPX
==================
<asp:DataList ID="dlCountry" runat="server">
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("customerid") %>'></asp:Label>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("CompanyName") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<asp:LinkButton ID="linkprev" runat="server" onclick="linkprev_Click">prev</asp:LinkButton>
<asp:LinkButton ID="lnknext" runat="server" onclick="lnknext_Click">next</asp:LinkButton>
</td>
</tr>
</table>
================================================
DEFAULT.ASPX.CS
===================================================
PagedDataSource pds = new PagedDataSource(); //GLOBAL DECLARATION
=====================
IN PAGE_LOAD
====================
if (!IsPostBack)
{
BindGrid();
}
=====================
public int CurrentPage
{
get
{
if (this.ViewState["CurrentPage"] == null)
return 0;
else
return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
}
set
{
this.ViewState["CurrentPage"] = value;
}
}
========
private void BindGrid()
{
string sql = "Select * from customers";
SqlDataAdapter da = new SqlDataAdapter(sql, "server=.;database=northwind;integrated security=true");
DataTable dt = new DataTable();
da.Fill(dt);
Cache["dt"] = dt;
pds.DataSource = dt.DefaultView;
pds.AllowPaging = true;
//pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
pds.CurrentPageIndex = CurrentPage;
lnknext.Enabled = !pds.IsLastPage;
linkprev.Enabled = !pds.IsFirstPage;
//doPaging();
dlCountry.DataSource = pds;
dlCountry.DataBind();
}
private void BindGrid1()
{
DataTable dt1 = new DataTable();
dt1 = (DataTable)Cache["dt"];
pds.DataSource = dt1.DefaultView;
pds.AllowPaging = true;
//pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
pds.CurrentPageIndex = CurrentPage;
lnknext.Enabled = !pds.IsLastPage;
linkprev.Enabled = !pds.IsFirstPage;
//doPaging();
dlCountry.DataSource = pds;
dlCountry.DataBind();
}
==================
protected void linkprev_Click(object sender, EventArgs e)
{
CurrentPage -= 1;
BindGrid1();
}
protected void lnknext_Click(object sender, EventArgs e)
{
CurrentPage += 1;
BindGrid1();
}
========================
URL
http://www.aspdotnetcodes.com/DataList_Dynamic_Paging_PagedDataSource.aspx
http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/datalistclassitemdatabound.aspx(good one)
http://www.eggheadcafe.com/tutorials/aspnet/d89d1d96-03f1-4784-bbb2-a3db1af393f5/aspnet-datalist-and-data.aspx(good one)
=========================================================================
In SQL-Server
create table emp(empid int,empname varchar(50),empdesc varchar(500))
datalist.aspx.cs
<asp:DataList Width="43%" ID="DataList1" runat="server" onitemdatabound="DataList1_ItemDataBound">;
<ItemTemplate>
<table width="50%">
<tr bgcolor="silver">
<td width="50%">
<asp:Label ID="lbl_1" runat="server" Text="first"></asp:Label>
</td>
<td width="50%">
<asp:Label ID="lbl_2" runat="server" Text="second"></asp:Label>
</td>
</tr>
<tr bgcolor="lime">
<td width="100%" colspan="2">
<asp:TextBox ID="txt_1" TextMode="multiLine" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
datalist.cs
SqlDataAdapter da;
DataTable dt= new DataTable();
int counter = 0;
in pageload event call this bind() method:
bind()
{
SqlConnection con = new SqlConnection("server=.;database=demo;integrated security=true;");
con.Open();
da = new SqlDataAdapter("select * from emp", con);
da.Fill(dt);
con.Close();
DataList1.DataSource = dt;
DataList1.DataBind();
}
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
Label lbl1 = (Label)e.Item.FindControl("lbl_1");
lbl1.Text = dt.Rows[counter][0].ToString();
Label lbl2 = (Label)e.Item.FindControl("lbl_2");
lbl2.Text = dt.Rows[counter][1].ToString();
TextBox txt = (TextBox)e.Item.FindControl("txt_1");
txt.Text = dt.Rows[counter][2].ToString();
counter++;
}
=============================
URL
=============================
http://aspalliance.com/157_Paging_in_DataList
http://www.c-sharpcorner.com/UploadFile/rizwan328/DataListCustomPaging01112009021450AM/DataListCustomPaging.aspx
http://www.aspdotnetcodes.com/DataList_Dynamic_Paging_PagedDataSource.aspx
======================================
PAGING IN DATALIST
==========================================
PLACE A DATALIST CONTROL AND INSIDE DATALIST PLACE TWO LABELS AS ITEM TEMPLATE
PLACE TWO LINK BUTTONS
DEFAULT.ASPX
==================
<asp:DataList ID="dlCountry" runat="server">
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("customerid") %>'></asp:Label>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("CompanyName") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<asp:LinkButton ID="linkprev" runat="server" onclick="linkprev_Click">prev</asp:LinkButton>
<asp:LinkButton ID="lnknext" runat="server" onclick="lnknext_Click">next</asp:LinkButton>
</td>
</tr>
</table>
================================================
DEFAULT.ASPX.CS
===================================================
PagedDataSource pds = new PagedDataSource(); //GLOBAL DECLARATION
=====================
IN PAGE_LOAD
====================
if (!IsPostBack)
{
BindGrid();
}
=====================
public int CurrentPage
{
get
{
if (this.ViewState["CurrentPage"] == null)
return 0;
else
return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
}
set
{
this.ViewState["CurrentPage"] = value;
}
}
========
private void BindGrid()
{
string sql = "Select * from customers";
SqlDataAdapter da = new SqlDataAdapter(sql, "server=.;database=northwind;integrated security=true");
DataTable dt = new DataTable();
da.Fill(dt);
Cache["dt"] = dt;
pds.DataSource = dt.DefaultView;
pds.AllowPaging = true;
//pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
pds.CurrentPageIndex = CurrentPage;
lnknext.Enabled = !pds.IsLastPage;
linkprev.Enabled = !pds.IsFirstPage;
//doPaging();
dlCountry.DataSource = pds;
dlCountry.DataBind();
}
private void BindGrid1()
{
DataTable dt1 = new DataTable();
dt1 = (DataTable)Cache["dt"];
pds.DataSource = dt1.DefaultView;
pds.AllowPaging = true;
//pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
pds.CurrentPageIndex = CurrentPage;
lnknext.Enabled = !pds.IsLastPage;
linkprev.Enabled = !pds.IsFirstPage;
//doPaging();
dlCountry.DataSource = pds;
dlCountry.DataBind();
}
==================
protected void linkprev_Click(object sender, EventArgs e)
{
CurrentPage -= 1;
BindGrid1();
}
protected void lnknext_Click(object sender, EventArgs e)
{
CurrentPage += 1;
BindGrid1();
}
========================
URL
http://www.aspdotnetcodes.com/DataList_Dynamic_Paging_PagedDataSource.aspx
http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/datalistclassitemdatabound.aspx(good one)
http://www.eggheadcafe.com/tutorials/aspnet/d89d1d96-03f1-4784-bbb2-a3db1af393f5/aspnet-datalist-and-data.aspx(good one)
=========================================================================
Thursday, December 17, 2009
DIFFERENCES...
DIFFERENCE BETWEEN CTYPE AND DIRECTCAST
================================================================================
Point#1
DirectCast requires the run-time type of an object variable to be the same as the specified type.The run-time performance of DirectCast is better than that of CType, if the specified type and the run-time typeof the expression are the same. Ctype works fine if there is a valid conversion defined between the expression and the type.
Point#2
The difference between the two keywords is that CType succeeds as long as there is a valid conversion defined between the expression and the type, whereas DirectCast requires the run-time type of an object variable to be the same as the specified type. If the specified type and the run-time type of the expression are the same, however, the run-time performance of DirectCast is better than that of CType.
================================================================================
UNIQUE KEY AND PRIMARY KEY
=================================================================================
Primary key and unique are Entity integrity constraints.
Primary key:
1)Primary key is nothing but it is uniqly identified each roe in Table.
2)Primary key Does not Allowes Duplicate values and Null values.
3)Primary key is default Clustered indexes
4)One table can have only one Primary key.
5) primary key can reference to other table as foreign key.
Unique Key:
1)Unique Key is nothing but it is uniqly identified each row in Table.
2)Unique Key Does not Allowes Duplicate values but allowes only one Null value.
3)Unique key is default Non- Clustered indexes
4)One table can have more number of Unique key
===================================================================================
NORMALIZATION
Normalization is the process of efficiently organizing data in a database. There are two goals of the normalization process: eliminating redundant data (for example, storing the same data in more than one table) and ensuring data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored.
The Normal Forms
The database community has developed a series of guidelines for ensuring that databases are normalized. These are referred to as normal forms and are numbered from one (the lowest form of normalization, referred to as first normal form or 1NF) through five (fifth normal form or 5NF). In practical applications, you'll often see 1NF, 2NF, and 3NF along with the occasional 4NF. Fifth normal form is very rarely seen and won't be discussed in this article.
Before we begin our discussion of the normal forms, it's important to point out that they are guidelines and guidelines only. Occasionally, it becomes necessary to stray from them to meet practical business requirements. However, when variations take place, it's extremely important to evaluate any possible ramifications they could have on your system and account for possible inconsistencies. That said, let's explore the normal forms.
First Normal Form (1NF)
First normal form (1NF) sets the very basic rules for an organized database:
* Eliminate duplicative columns from the same table.
* Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).
Second Normal Form (2NF)
Second normal form (2NF) further addresses the concept of removing duplicative data:
* Meet all the requirements of the first normal form.
* Remove subsets of data that apply to multiple rows of a table and place them in separate tables.
* Create relationships between these new tables and their predecessors through the use of foreign keys.
Third Normal Form (3NF)
Third normal form (3NF) goes one large step further:
* Meet all the requirements of the second normal form.
* Remove columns that are not dependent upon the primary key.
Fourth Normal Form (4NF)
Finally, fourth normal form (4NF) has one additional requirement:
* Meet all the requirements of the third normal form.
* A relation is in 4NF if it has no multi-valued dependencies.
URL:http://databases.about.com/od/specificproducts/a/normalization.htm
===========================================================================
DIFFERENCE BETWEEN REPEATOR,DATALIST AND GRIDVIEW CONTROLS
===========================================================
Explanation:
In ASP .NET basically there are three kinds of the Data Presentation Controls.
1. GridView (or DataGrid)
2. DataList
3. Repeater
When we talk about usage of one Data Presentation Controls then many of us get confused about choosing one. When you need to use one of the data Presentation Control then You have to see what kind of behavior you need in your Data Display.
1. Do you want to show Data in many Pages or in one page?
2. Do you have to Display more then one column in a Row ?
3. Do you want to have a Row repeating Possibility?
4. Will users be able to update, Insert and delete the Data?
We are going provide a list of different abilities of Repeater Control, Datalist Control and GridView Control.
Features of a GridView
•Displays data as a table
•Control over
–Alternate item
–Header
–Footer
–Colors, font, borders, etc.
–Paging
•Updateable
•Item as row
Features of Repeater
•List format
•No default output
•More control
•More complexity
•Item as row
•Not updateable
Features of DataList
•Directional rendering
•Good for columns
•Item as cell
•Alternate item
•Updateable
===============================================================
Difference between Datagrid,DataList and Data Repeater:
* Datagrid has paging while Datalist doesnt.
* Datalist has a property called repeat. Direction = vertical/horizontal. (This is of great help in designing layouts). This is not there inDatagrid.
* A repeater is used when more intimate control over html generation is required.
* When only checkboxes/radiobuttons are repeatedly served then a checkboxlist or radiobuttonlist are used as they involve fewer overheads than aDatagrid.
The Repeater repeats a layout of HTML you write, it has the least functionality of the three. DataList is the next step up from a Repeater; accept you have very little control over the HTML that the control renders. DataList is the first of the three controls that allow you Repeat-Columns horizontally or vertically. Finally, the DataGrid is the motherload. However, instead of working on a row-by-row basis, you’re working on a column-by-column basis. DataGrid caters to sorting and has basic paging for your disposal. Again you have little contro, over the HTML. NOTE: DataList and DataGrid both render as HTML tables by default.
===========================================================================
URL
http://www.dotnet-friends.com/fastcode/asp/fastcodeinasp140ee486-9653-4807-bf04-aee4d5696991.aspx
http://24x7aspnet.blogspot.com/2009/06/feature-difference-between.html
===========================================================================
================================================================================
Point#1
DirectCast requires the run-time type of an object variable to be the same as the specified type.The run-time performance of DirectCast is better than that of CType, if the specified type and the run-time typeof the expression are the same. Ctype works fine if there is a valid conversion defined between the expression and the type.
Point#2
The difference between the two keywords is that CType succeeds as long as there is a valid conversion defined between the expression and the type, whereas DirectCast requires the run-time type of an object variable to be the same as the specified type. If the specified type and the run-time type of the expression are the same, however, the run-time performance of DirectCast is better than that of CType.
================================================================================
UNIQUE KEY AND PRIMARY KEY
=================================================================================
Primary key and unique are Entity integrity constraints.
Primary key:
1)Primary key is nothing but it is uniqly identified each roe in Table.
2)Primary key Does not Allowes Duplicate values and Null values.
3)Primary key is default Clustered indexes
4)One table can have only one Primary key.
5) primary key can reference to other table as foreign key.
Unique Key:
1)Unique Key is nothing but it is uniqly identified each row in Table.
2)Unique Key Does not Allowes Duplicate values but allowes only one Null value.
3)Unique key is default Non- Clustered indexes
4)One table can have more number of Unique key
===================================================================================
NORMALIZATION
Normalization is the process of efficiently organizing data in a database. There are two goals of the normalization process: eliminating redundant data (for example, storing the same data in more than one table) and ensuring data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored.
The Normal Forms
The database community has developed a series of guidelines for ensuring that databases are normalized. These are referred to as normal forms and are numbered from one (the lowest form of normalization, referred to as first normal form or 1NF) through five (fifth normal form or 5NF). In practical applications, you'll often see 1NF, 2NF, and 3NF along with the occasional 4NF. Fifth normal form is very rarely seen and won't be discussed in this article.
Before we begin our discussion of the normal forms, it's important to point out that they are guidelines and guidelines only. Occasionally, it becomes necessary to stray from them to meet practical business requirements. However, when variations take place, it's extremely important to evaluate any possible ramifications they could have on your system and account for possible inconsistencies. That said, let's explore the normal forms.
First Normal Form (1NF)
First normal form (1NF) sets the very basic rules for an organized database:
* Eliminate duplicative columns from the same table.
* Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).
Second Normal Form (2NF)
Second normal form (2NF) further addresses the concept of removing duplicative data:
* Meet all the requirements of the first normal form.
* Remove subsets of data that apply to multiple rows of a table and place them in separate tables.
* Create relationships between these new tables and their predecessors through the use of foreign keys.
Third Normal Form (3NF)
Third normal form (3NF) goes one large step further:
* Meet all the requirements of the second normal form.
* Remove columns that are not dependent upon the primary key.
Fourth Normal Form (4NF)
Finally, fourth normal form (4NF) has one additional requirement:
* Meet all the requirements of the third normal form.
* A relation is in 4NF if it has no multi-valued dependencies.
URL:http://databases.about.com/od/specificproducts/a/normalization.htm
===========================================================================
DIFFERENCE BETWEEN REPEATOR,DATALIST AND GRIDVIEW CONTROLS
===========================================================
Explanation:
In ASP .NET basically there are three kinds of the Data Presentation Controls.
1. GridView (or DataGrid)
2. DataList
3. Repeater
When we talk about usage of one Data Presentation Controls then many of us get confused about choosing one. When you need to use one of the data Presentation Control then You have to see what kind of behavior you need in your Data Display.
1. Do you want to show Data in many Pages or in one page?
2. Do you have to Display more then one column in a Row ?
3. Do you want to have a Row repeating Possibility?
4. Will users be able to update, Insert and delete the Data?
We are going provide a list of different abilities of Repeater Control, Datalist Control and GridView Control.
Features of a GridView
•Displays data as a table
•Control over
–Alternate item
–Header
–Footer
–Colors, font, borders, etc.
–Paging
•Updateable
•Item as row
Features of Repeater
•List format
•No default output
•More control
•More complexity
•Item as row
•Not updateable
Features of DataList
•Directional rendering
•Good for columns
•Item as cell
•Alternate item
•Updateable
===============================================================
Difference between Datagrid,DataList and Data Repeater:
* Datagrid has paging while Datalist doesnt.
* Datalist has a property called repeat. Direction = vertical/horizontal. (This is of great help in designing layouts). This is not there inDatagrid.
* A repeater is used when more intimate control over html generation is required.
* When only checkboxes/radiobuttons are repeatedly served then a checkboxlist or radiobuttonlist are used as they involve fewer overheads than aDatagrid.
The Repeater repeats a layout of HTML you write, it has the least functionality of the three. DataList is the next step up from a Repeater; accept you have very little control over the HTML that the control renders. DataList is the first of the three controls that allow you Repeat-Columns horizontally or vertically. Finally, the DataGrid is the motherload. However, instead of working on a row-by-row basis, you’re working on a column-by-column basis. DataGrid caters to sorting and has basic paging for your disposal. Again you have little contro, over the HTML. NOTE: DataList and DataGrid both render as HTML tables by default.
===========================================================================
URL
http://www.dotnet-friends.com/fastcode/asp/fastcodeinasp140ee486-9653-4807-bf04-aee4d5696991.aspx
http://24x7aspnet.blogspot.com/2009/06/feature-difference-between.html
===========================================================================
Subscribe to:
Posts (Atom)