Sunday, August 8, 2010

Fetch out More than 3 entries for one name and class column

Suppose you want to Fetch out More than 3 entries in a class with the same name of student, than you can use following query:
Here Id is table's primary key.

Select * from Table1 t6
where Id < (select MAX(Id) from (Select * from Table1 t4
where Id < (select max(Id) from (Select * from Table1 t2
where Id < (select Max(Id)from Table1 t1 where t1.name = t2.name and t1.class = t2.class)) t3 where t4.class= t3.class and t4.name = t3.name )) t5 where t6.class= t5.class and t6.name = t5.name )
order by t6.name desc



Thanks.

Generate Crystal Report from a Datatable and export it to HTML Report.

Select all data in a DataTable dt which you want to display in Report than make a form to display report FrmReportShow,put a CrystalReportViewer on it.
Insert a Crystal Report Report1 and a DataSet1 in your application and create a DataTable1 in Dataset1 and insert all columns that you want to display on report than set crystal report datasource to dataset1.


DataSet1 d = new DataSet1();
Report1 objRpt=new Report1();
foreach (DataRow dr in dt.Rows)
{
d.DataTable1.Rows.Add(dr.ItemArray);
}
FrmReportShow frs = new FrmReportShow();
ParameterField paramfield = new ParameterField();
ParameterFields paramfields = new ParameterFields();
ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
discreteval.Value = "Transferred";
paramfield.CurrentValues.Add(discreteval);
paramfields.Add(paramfield);
frs.crystalReportViewer1.ParameterFieldInfo = paramfields;
objRpt.SetDataSource(d);
frs.crystalReportViewer1.ReportSource = objRpt;
frs.crystalReportViewer1.Refresh();
objRpt.SetParameterValue("ReportType", "Not Transferred");

//Export Report to HTML

objRpt.ExportToDisk(ExportFormatType.HTML40, Application.StartupPath + "\\Report\\Report.html");
frs.Show();


-------------------------------
if have any query than ask.


Thanks.

A Term iFusion.net, What is this?

iFusion.net is some new term for our IT Field. This term is come from IBM i and Microsoft combination which provide facilities to organizations that now they can use IBM system with Microsoft applications which are built in .NET framework like SQL Server,Office etc.
This technology is the only one in IT industry in which two huge system combine into one.It is a complete solution with addressing presentation, business logic and database issues from a single platform.
By using fusion, the limitation of interoperability is near about remove which we occurred in many solutions like calling programs, replicating databases or transferring files – to create true composite applications that deliver real-time enterprise data and functionality to people as they need it.

Requirement/Importance of iFusion.net?

Many organizations use a combined IT environment that is difficult or complex to handle and constrains the responsiveness of the IT resources to changing business needs. All organizations need choice in how they build and deploy applications, but the choice is practical only when the IT resources can operate as a harmonized unit. iFusion.net gives solution by combining the IBM i and Windows platforms into a fused consolidated whole, where you build applications on the most appropriate platform or distribute across both. iFusion.net provide the things as follows :

* Gives appropriate faster action when responding to changing business needs.
* Accommodate choice for development options, preferences and available skills.
* Secure investment in the current assets – concern with people and applications.
* Mix the both of IBM i and Windows platforms.
* Build a flexible road map ranging from quick modernization to a full migration.
* Provide security and data integrity at every step.

Some Examples of iFusion.net :

There are much of important points between the IBM i system and Microsoft solutions:

* Fusing an e-commerce Web site which was built in ASP.NET to an IBM i ERP system, thereby publishing up-to-the-second inventory and pricing information along with straight-through order processing.
* Use or Fetch live operational data on the IBM i database (DB2) directly from a Windows or Web-based dashboard, without having any terminal session or toggle between multiple screens.
* Enhancing collaboration and work flow automation by combining tasks that use both Windows and IBM i functionality (including program logic, data queues and access to the IFS) inside a Microsoft Share Point enterprise portal with support for single sign-on.
* Provide all of Visual Studio.NET developers the authority to perform create, read, update and delete actions on the core databases — without risk of destroying data integrity or security.

For more details, visit http://www.ifusion.net/details.htm

Tuesday, August 3, 2010

How to Refresh a Web Page Automatically ??

There are Two way to refresh a web page


1. "."

2.This is the ASP.Net way
Response.AppendHeader("Refresh", "10; URL=http://www.dotnetspider.com")

ACRONYM HTML Tag

Ex: Get this ASAP

An acronym can be spoken as if it were a word, example NATO, NASA, ASAP, GUI.

By marking up acronyms you can give useful information to browsers, spellcheckers, screen readers, translation systems and search-engines.

To select nth row From a table

declare @num as int
set @num=3
select * from table1 a where @num=(select count(*) from table1 b where a.uid >= b.uid)

Monday, August 2, 2010

Use of Sql Exists Clause.

SQL: EXISTS Condition

The EXISTS condition is considered "to be met" if the subquery returns at least one row.

The syntax for the EXISTS condition is:

    SELECT columns
    FROM tables
    WHERE EXISTS ( subquery );

The EXISTS condition can be used in any valid SQL statement - select, insert, update, or delete.

Example #1

Let's take a look at a simple example. The following is an SQL statement that uses the EXISTS condition:

    SELECT *
    FROM suppliers
    WHERE EXISTS
      (select *
        from orders
        where suppliers.supplier_id = orders.supplier_id);

This select statement will return all records from the suppliers table where there is at least one record in the orders table with the same supplier_id.

DIFFRENCE BETWEEN GARBAGE COLLECTION AND DISPOSE METHOD.

(*) Garbage Collection is the .NET Framework way of freeing and releasing the memory occupied by managed objects of the .Net Object Oriented Programming model. The Garbage Collection is called by runtime to free memory used by "managed" resources.

(*) IDisposable.Dispose() method is also meant for same action of freeing resources. But in additon, you can make its best use to free "unmanaged" resources.

Now, what are the unmanaged resources. Unmanaged resources are such as Files, NetWork, Streams and COM types. So in this case these resources unnecessarily unknowingly consume much resources & GC also not helps.

Use of SqlBulkCopy Function to insert row in Bulk in table.

System.Data.DataTable table = dt;
SqlConnection cn = new SqlConnection(dbc.Constr.ToString());  
SqlBulkCopy cc = new SqlBulkCopy(cn);
cc.DestinationTableName = "dbo.Temp_Report";
cn.Open();
cc.WriteToServer(table);
cn.Close();