URL
-----------------
http://www.beansoftware.com/ASP.NET-Tutorials/Tracing-ASP.NET.aspx
http://www.asp101.com/articles/robert/tracing/default.asp
http://authors.aspalliance.com/aspxtreme/webapps/tracefunctionality.aspx
http://www.dotnetheaven.com/UploadFile/prathore/Tracing10122007030241AM/Tracing.aspx
------------
Hunt
Monday, May 31, 2010
Saturday, May 22, 2010
COLLECTIONS AND GENERICS
URL
---------------
http://www.developer.com/net/net/article.php/3403481/Using-Lists-and-Collections-in-NET.htm
http://articles.techrepublic.com.com/5100-10878_11-1045372.html
http://www.codeguru.com/csharp/.net/net_asp/tutorials/article.php/c11887/Understanding-Generic-Classes.htm
http://www.dotnetspider.com/resources/31000-Binding-Gridview-using-Generics-from-Database.aspx
http://www.dotnetspider.com/resources/20675-Difference-between-Arraylist-Generic-List.aspx
EXAMPLES
---------------------------------
http://www.codeproject.com/KB/aspnet/Generics.aspx
http://www.dotnetjohn.com/articles.aspx?articleid=250
http://www.switchonthecode.com/tutorials/csharp-tutorial-binding-a-datagridview-to-a-collection
-----------------------------------
ABOUT GENERICS
---------------------------
Generic Types
Generics are the most powerful feature of C# 2.0. It allows defining type-safe data structures, without committing to actual data types. In C# 1.0 we can either declare reference type or value type. But in most of the application we come across situation where we need type that can hold both reference & value type. In such situation we use generic types.
Why Generics?
1.
Generic type doesn't care what the type is. We can specify the type at runtime.
2.
It avoids boxing difficulties. In C# 1.0, if we want to put any object into a List, Stack, or Queue objects, we have to take type as System.Object.
3.
It boosts the performance of the application because we can reuse data processing algorithm without duplicating type-specific code.
How Generic implemented:
(1) Generic type is instantiated at run-time not compiled time
(2) Generic type are checked at time of declaration not at instantiation
(3) It works for both reference type & value type.
The System.Collections.Generic Namespace
The System.Collections.Generic namespace contains several generic collection classes based on generics and it is recommended that we should use these collection classes in lieu of the earlier non-generic ones for better performance of our applications.
According to MSDN, "The System.Collections.Generic namespace contains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections."
Note that the System.Collections.Generic.ICollection interface is the base interface for all the classes in the System.Collections.Generic namespace.
---------------------------------------------------------
url
http://www.c-sharpcorner.com/UploadFile/abhishekbhatore/GenericTypeWithSample07292005092634AM/GenericTypeWithSample.aspx
--------------------------------
---------------
http://www.developer.com/net/net/article.php/3403481/Using-Lists-and-Collections-in-NET.htm
http://articles.techrepublic.com.com/5100-10878_11-1045372.html
http://www.codeguru.com/csharp/.net/net_asp/tutorials/article.php/c11887/Understanding-Generic-Classes.htm
http://www.dotnetspider.com/resources/31000-Binding-Gridview-using-Generics-from-Database.aspx
http://www.dotnetspider.com/resources/20675-Difference-between-Arraylist-Generic-List.aspx
EXAMPLES
---------------------------------
http://www.codeproject.com/KB/aspnet/Generics.aspx
http://www.dotnetjohn.com/articles.aspx?articleid=250
http://www.switchonthecode.com/tutorials/csharp-tutorial-binding-a-datagridview-to-a-collection
-----------------------------------
ABOUT GENERICS
---------------------------
Generic Types
Generics are the most powerful feature of C# 2.0. It allows defining type-safe data structures, without committing to actual data types. In C# 1.0 we can either declare reference type or value type. But in most of the application we come across situation where we need type that can hold both reference & value type. In such situation we use generic types.
Why Generics?
1.
Generic type doesn't care what the type is. We can specify the type at runtime.
2.
It avoids boxing difficulties. In C# 1.0, if we want to put any object into a List, Stack, or Queue objects, we have to take type as System.Object.
3.
It boosts the performance of the application because we can reuse data processing algorithm without duplicating type-specific code.
How Generic implemented:
(1) Generic type is instantiated at run-time not compiled time
(2) Generic type are checked at time of declaration not at instantiation
(3) It works for both reference type & value type.
The System.Collections.Generic Namespace
The System.Collections.Generic namespace contains several generic collection classes based on generics and it is recommended that we should use these collection classes in lieu of the earlier non-generic ones for better performance of our applications.
According to MSDN, "The System.Collections.Generic namespace contains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections."
Note that the System.Collections.Generic.ICollection
---------------------------------------------------------
url
http://www.c-sharpcorner.com/UploadFile/abhishekbhatore/GenericTypeWithSample07292005092634AM/GenericTypeWithSample.aspx
--------------------------------
Tuesday, April 27, 2010
WINDOWS APPLICATION COMMON FUNCTIONS..
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);
}
-----------------------------------------------
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);
}
-----------------------------------------------
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");
==============================================================
Subscribe to:
Posts (Atom)