Hi this is my first post.. i am really getting confused regarding trigger.. please correct me if am wrong there is no way we can get output from trigger into our web forms.. right ?? So my question is what is the main use of trigger in a application and also if possible please tell me can i use in my online shopping system if its possible please clarify this using real world example. I know basic of that we can bind trigger or register trigger with some command like insert delete and so on. Is it only use for testing purpose only ?? Please i am not able to find any answer on google please help me out with this.
IT Solution
For Any Problem Their is Always Exist a Solution only U Have To Find
Wednesday, 24 July 2013
Monday, 19 November 2012
Display XML in Table Format
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(strXml);
xmlReader = new XmlNodeReader(xmlDoc);
<table cellpadding="3" cellspacing="0" border="0" width="98%" class="border">
<tr class="hrow">
<th>
Name</th>
<th>
Value</th>
</tr>
<%while (xmlReader.Read())
{ %>
<tr style="background-color: #E0E6F8; font-weight: bold;">
<td colspan="2">
<%=xmlReader.Name%>
</td>
</tr>
<%if (xmlReader.HasAttributes)
{ %>
<% while (xmlReader.MoveToNextAttribute())
{%>
<tr>
<td>
<%=xmlReader.Name%>
</td>
<td>
<%=xmlReader.Value%>
</td>
</tr>
<%} %>
<% xmlReader.MoveToElement(); %>
<%} %>
<%} %>
</table>
xmlDoc.LoadXml(strXml);
xmlReader = new XmlNodeReader(xmlDoc);
<table cellpadding="3" cellspacing="0" border="0" width="98%" class="border">
<tr class="hrow">
<th>
Name</th>
<th>
Value</th>
</tr>
<%while (xmlReader.Read())
{ %>
<tr style="background-color: #E0E6F8; font-weight: bold;">
<td colspan="2">
<%=xmlReader.Name%>
</td>
</tr>
<%if (xmlReader.HasAttributes)
{ %>
<% while (xmlReader.MoveToNextAttribute())
{%>
<tr>
<td>
<%=xmlReader.Name%>
</td>
<td>
<%=xmlReader.Value%>
</td>
</tr>
<%} %>
<% xmlReader.MoveToElement(); %>
<%} %>
<%} %>
</table>
Saturday, 30 June 2012
Method To Create The PDF File From GridView In Asp.net
protected void ExportToPDF(GridView gvuser, string fileName, bool isLastColVisible, bool isLogo)
{
if (gvuser == null)
return;
if (string.IsNullOrEmpty(fileName))
fileName = "Bucco.pdf";
gvuser = PrepareGridViewForExport(gvuser);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
if (!isLastColVisible)
gvuser.Columns[gvuser.Columns.Count - 1].Visible = false;
//gvuser.RowStyle.Height = 20;
//gvuser.HeaderRow.Style.Add("height", "20px");
gvuser.GridLines = GridLines.Vertical;
gvuser.HeaderStyle.BackColor = System.Drawing.Color.Green;
gvuser.HeaderRow.Style.Add("background", "green");
gvuser.HeaderRow.Style.Add("font-size", "8px");
gvuser.Style.Add("text-decoration", "none");
gvuser.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
gvuser.Style.Add("font-size", "6px");
gvuser.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(gvuser);
frm.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
if (isLogo)
{
iTextSharp.text.Image gif = iTextSharp.text.Image.GetInstance(Server.MapPath("~/App_Themes/buco/images/logo.jpg"));
pdfDoc.Add(gif);
}
pdfDoc.Add(new Paragraph(fileName.Substring(0, fileName.IndexOf('.'))));
pdfDoc.Add(new Paragraph(" "));
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
Read Data From Excel Sheet In ASP.net or create dataset from excel sheet
Here The Simple Method Which Make DataSet From Excel Sheet
Public dataset dataSetFromExcel(string filePath)
{
string SheetName = GetExcelSheetNames( filePath );
string constring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;'";
OleDbConnection con = new OleDbConnection(constring);
string sql = "select * from [" + SheetName + "]";
OleDbDataAdapter da = new OleDbDataAdapter(sql, con);
da.TableMappings.Add("Table", SheetName);
try
{
da.Fill(ds);
if (ds.Tables.Count > 0)
{
ViewState["data"] = ds;
}
}
catch (Exception ex)
{
ex.ToString();
}
finally
{
if (con != null)
{
con.Close();
con.Dispose();
}
}
}
public static string GetExcelSheetNames(string excelFile)
{
OleDbConnection objConn = null;
DataTable dt = null;
try
{
String connString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + excelFile + "';Extended Properties=Excel 8.0;";
objConn = new OleDbConnection(connString);
objConn.Open();
dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (dt == null)
{
return null;
}
string SheetName = "";
if (dt.Rows.Count > 0)
{
SheetName = dt.Rows[0]["TABLE_NAME"].ToString();
}
return SheetName;
}
catch (Exception ex)
{
ex.ToString();
return null;
}
finally
{
if (objConn != null)
{
objConn.Close();
objConn.Dispose();
}
if (dt != null)
{
dt.Dispose();
}
}
}
Public dataset dataSetFromExcel(string filePath)
{
string SheetName = GetExcelSheetNames( filePath );
string constring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;'";
OleDbConnection con = new OleDbConnection(constring);
string sql = "select * from [" + SheetName + "]";
OleDbDataAdapter da = new OleDbDataAdapter(sql, con);
da.TableMappings.Add("Table", SheetName);
try
{
da.Fill(ds);
if (ds.Tables.Count > 0)
{
ViewState["data"] = ds;
}
}
catch (Exception ex)
{
ex.ToString();
}
finally
{
if (con != null)
{
con.Close();
con.Dispose();
}
}
}
public static string GetExcelSheetNames(string excelFile)
{
OleDbConnection objConn = null;
DataTable dt = null;
try
{
String connString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + excelFile + "';Extended Properties=Excel 8.0;";
objConn = new OleDbConnection(connString);
objConn.Open();
dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (dt == null)
{
return null;
}
string SheetName = "";
if (dt.Rows.Count > 0)
{
SheetName = dt.Rows[0]["TABLE_NAME"].ToString();
}
return SheetName;
}
catch (Exception ex)
{
ex.ToString();
return null;
}
finally
{
if (objConn != null)
{
objConn.Close();
objConn.Dispose();
}
if (dt != null)
{
dt.Dispose();
}
}
}
Create Generic List From Reader In ASP.net
Here The Code By Using Which We Can Create a list from reader in C# ASP.net
public List<T> SelectAll(string constr, string table, object val)
{
List<T> list = new List<T>();
try
{
SqlConnection conn = Tools.GetConnection(constr);
IDbCommand command = Tools.GetSelectCommand(table, conn, "id", val);
IDataReader reader = command.ExecuteReader();
list = Cbo.FillCollection<T>(reader);
constr.cloase();
}
catch (Exception)
{
throw;
}
return list;
}
public static List<T> FillCollection<T>(IDataReader dr)
{
List<T> objFillCollection = new List<T>();
T objFillObject;
while (dr.Read())
{
// fill business object
objFillObject = CreateObject<T>(dr);
// add to collection
objFillCollection.Add(objFillObject);
}
if (!(dr == null))
{
dr.Close();
}
return objFillCollection;
}
private static T CreateObject<T>(IDataReader dr)
{
Type objType = null;
T obj = Activator.CreateInstance<T>();
List<PropertyInfo> properties = Helper.GetPropertyInfo(typeof(T));
int i;
for (i = 0; i < dr.FieldCount; i++)
{
string columnName = dr.GetName(i);
//now find matching property
PropertyInfo propMatch = properties.Find(delegate(PropertyInfo p)
{
Type t = typeof(T);
PropertyInfo pi = t.GetProperty(p.Name);
Column[] atrb = pi.GetCustomAttributes(typeof(Column), false) as Column[];
if (atrb != null)
{
if (atrb.Length > 0)
{
foreach (Column at in atrb)
if (at != null && !string.IsNullOrEmpty(at.Name))
{
return at.Name.ToLower() == columnName.ToLower();
}
}
}
return p.Name.ToLower() == columnName.ToLower();
});
if (propMatch != null)
{
//we have found a matching property. fill it in
if (Convert.IsDBNull(dr.GetValue(i)))
{
propMatch.SetValue(obj, Null.GetNull(propMatch), null);
}
else
{
try
{
// try implicit conversion first
propMatch.SetValue(obj, dr.GetValue(i), null);
}
catch
{
try
{
objType = propMatch.PropertyType;
// need to handle enumeration conversions differently than other base types
if (objType.BaseType.Equals(typeof(System.Enum)))
{
if (Helper.IsNumeric(dr.GetValue(i)))
{
propMatch.SetValue(obj, System.Enum.ToObject(objType, Convert.ToInt32(dr.GetValue(i))), null);
}
else
{
propMatch.SetValue(obj, System.Enum.ToObject(objType, dr.GetValue(i)), null);
}
}
else
{
propMatch.SetValue(obj, Convert.ChangeType(dr.GetValue(i), objType), null);
}
}
catch
{
propMatch.SetValue(obj, Convert.ChangeType(dr.GetValue(i), objType), null);
}
}
}
}
else
{
Console.WriteLine("property not found {0}", typeof(T).Name);
}
}
return obj;
}
FireFox Descriptions
For Debugging of FireFox FireBug
For Coloring System rainbow
for screenshots AweSome Screen Shot for firefox
For Coloring System rainbow
for screenshots AweSome Screen Shot for firefox
Thursday, 21 June 2012
Converting DataReader To generic List Using C#...
First make one class having similar attribute as you database table for eg: public class Student { public int ID { get; set; } public string Name { get; set; } public DateTime DateOfBirth { get; set; } } after that List<Student> student = new List<Student>(); SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Prac\TestAssembly\ForumsProjectCSharp\App_Data\Studetnt.mdf;Integrated Security=True;User Instance=True"); SqlCommand cmd = new SqlCommand("select * from Student", conn); SqlDataReader dr; try { conn.Open(); dr = cmd.ExecuteReader(); while (dr.Read()) { student.Add(new Student() { ID = dr.GetInt32(dr.GetOrdinal("ID")), Name = dr.GetString(dr.GetOrdinal("Name")), DateOfBirth = dr.GetDateTime(dr.GetOrdinal("DateOfBirth")) }); } dr.Close(); } catch (Exception exp) { throw; } finally { conn.Close(); }
Wednesday, 13 June 2012
new features added to sql server 2008
• Database mirroring. Microsoft first introduced this feature
in SQL Server 2005 and enhanced it in SQL Server 2008.
Database mirroring provides data administrators a low-cost
disaster recovery solution.
• Service Broker. SQL Server Service Broker provides an
integrated infrastructure on which developers can create
asynchronous messaging applications.
• Policy-based management. SQL Server 2008 lets you
automatically enforce and monitor policies for database
operations. You can also push these policies to your servers.
• Resource Governor. The Resource Governor lets you limit
the resource consumption of incoming requests by
classifying incoming connections as specific workload types
and defining limits for those types. You can also redefine the
limits in real time.
• Backup compression. SQL Server 2008 can automatically
compress database backups, a feature previously available
only via the purchase of third-party software products.
• Performance data collection. SQL Server 2008 lets you
store performance data in a centralized database. It also
provides enhanced tools for analyzing and reporting on such
performance data.
• New data types. The new SQL Server 2008 FILESTREAM
data type allows you to store large binary data, such as
documents or images, directly in an NTFS file system. Other
new data types include support for spatial data and the time
date type.
• “Hot add” hardware. First introduced in SQL Server 2005,
hot add memory helps system administrators decrease
downtime when important memory upgrades are necessary.
On supported hardware platforms, SQL Server 2008 also lets
you add one or more CPUs while the program is running.
What's Difference Between SQL Server 2005 And SQL Server 2008..
In sql server 2005,There is no option to compress backup files, but in sql server 2008,there you find it.
storing backup file takes 5 minutes without compression in sqlserver 2005,but it takes only 3 minutes in sql server 2008 for storing backup files with compression.
CPU is used to compress the data before it is written to disk,so less data is written to disk.
There are many new features, so it depends on what you need. If you store large files in SQL Server, migrated from Oracle and want to use date and time data types, need to encrypt your databases, etc you will definitely want to look at 2008. The nice thing is that it upgrading should be much easier from 2005 to 2008 than it was from 2000 to 2005.
Server 2008 also added CMS which is Central Management Server. It only works with Windows Authentication but it allows you to management multiple SQL Servers at once. If SQL Server systems are popping up like weeds it will appear in the CMS provided that they point to the CMS via SSMS. Its a really cool feature.
PBM Policy-Based Management is another added feature introduced with SQL Server 2008. PBM allows you to define and enforce policies for configuring and managing SQL Server across your enterprise. It goes hand-in-hand with CMS.
One of my favorite is that fact that Reporting Services no longer requires IIS as it makes direct calls to HTTP.SYS.
SQL2008 has support for additional datatypes:
date
time
geospatial
timestamp with internal timezone
Tuesday, 5 June 2012
How I Make Excel Sheet From Genric List In Asp.net??
This Is The Complete Method To export List Item Into Excel
public void ExportToExcel<T>(List<T> list)
{
int columnCount = 0;
DateTime StartTime = DateTime.Now;
StringBuilder rowData = new StringBuilder();
PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
rowData.Append("<Row ss:StyleID=\"s62\">");
foreach (PropertyInfo p in properties)
{
if (p.PropertyType.Name != "EntityCollection`1" && p.PropertyType.Name != "EntityReference`1" && p.PropertyType.Name != p.Name)
{
columnCount++;
rowData.Append("<Cell ss:StyleID=\"s62\"><Data ss:Type=\"String\">" + p.Name + "</Data></Cell>");
}
else
break;
}
rowData.Append("</Row>");
foreach (T item in list)
{
rowData.Append("<Row>");
for (int x = 0; x < columnCount; x++) //each (PropertyInfo p in properties)
{
object o = properties[x].GetValue(item, null);
string value = o == null ? "" : o.ToString();
rowData.Append("<Cell ><Data ss:Type=\"String\">" + value + "</Data></Cell>");
}
rowData.Append("</Row>");
}
var sheet = @"<?xml version=""1.0""?>
<?mso-application progid=""Excel.Sheet""?>
<Workbook xmlns=""urn:schemas-microsoft-com:office:spreadsheet""
xmlns:o=""urn:schemas-microsoft-com:office:office""
xmlns:x=""urn:schemas-microsoft-com:office:excel""
xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet""
xmlns:html=""http://www.w3.org/TR/REC-html40"">
<DocumentProperties xmlns=""urn:schemas-microsoft-com:office:office"">
<Author>MSADMIN</Author>
<LastAuthor>MSADMIN</LastAuthor>
<Created>2011-07-12T23:40:11Z</Created>
<Company>Microsoft</Company>
<Version>12.00</Version>
</DocumentProperties>
<ExcelWorkbook xmlns=""urn:schemas-microsoft-com:office:excel"">
<WindowHeight>6600</WindowHeight>
<WindowWidth>12255</WindowWidth>
<WindowTopX>0</WindowTopX>
<WindowTopY>60</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID=""Default"" ss:Name=""Normal"">
<Alignment ss:Vertical=""Bottom""/>
<Borders/>
<Font ss:FontName=""Calibri"" x:Family=""Swiss"" ss:Size=""11"" ss:Color=""#000000""/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID=""s62"">
<Font ss:FontName=""Calibri"" x:Family=""Swiss"" ss:Size=""11"" ss:Color=""#000000"" ss:Bold=""1""/>
</Style>
</Styles>
<Worksheet ss:Name=""Sheet1"">
<Table ss:ExpandedColumnCount=""" + (properties.Count() + 1) + @""" ss:ExpandedRowCount=""" + (list.Count() + 1) + @""" x:FullColumns=""1"" x:FullRows=""1"" ss:DefaultRowHeight=""15"">
" + rowData.ToString() + @"
</Table>
<WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">
<PageSetup>
<Header x:Margin=""0.3""/>
<Footer x:Margin=""0.3""/>
<PageMargins x:Bottom=""0.75"" x:Left=""0.7"" x:Right=""0.7"" x:Top=""0.75""/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<HorizontalResolution>300</HorizontalResolution>
<VerticalResolution>300</VerticalResolution>
</Print>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveCol>2</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name=""Sheet2"">
<Table ss:ExpandedColumnCount=""1"" ss:ExpandedRowCount=""1"" x:FullColumns=""1"" x:FullRows=""1"" ss:DefaultRowHeight=""15"">
</Table>
<WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">
<PageSetup>
<Header x:Margin=""0.3""/>
<Footer x:Margin=""0.3""/>
<PageMargins x:Bottom=""0.75"" x:Left=""0.7"" x:Right=""0.7"" x:Top=""0.75""/>
</PageSetup>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name=""Sheet3"">
<Table ss:ExpandedColumnCount=""1"" ss:ExpandedRowCount=""1"" x:FullColumns=""1"" x:FullRows=""1"" ss:DefaultRowHeight=""15"">
</Table>
<WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">
<PageSetup>
<Header x:Margin=""0.3""/>
<Footer x:Margin=""0.3""/>
<PageMargins x:Bottom=""0.75"" x:Left=""0.7"" x:Right=""0.7"" x:Top=""0.75""/>
</PageSetup>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>";
System.Diagnostics.Debug.Print(StartTime.ToString() + " - " + DateTime.Now);
System.Diagnostics.Debug.Print((DateTime.Now - StartTime).ToString());
string attachment = "attachment; filename=Report.xls";
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", attachment);
HttpContext.Current.Response.Write(sheet);
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.End();
}
public void ExportToExcel<T>(List<T> list)
{
int columnCount = 0;
DateTime StartTime = DateTime.Now;
StringBuilder rowData = new StringBuilder();
PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
rowData.Append("<Row ss:StyleID=\"s62\">");
foreach (PropertyInfo p in properties)
{
if (p.PropertyType.Name != "EntityCollection`1" && p.PropertyType.Name != "EntityReference`1" && p.PropertyType.Name != p.Name)
{
columnCount++;
rowData.Append("<Cell ss:StyleID=\"s62\"><Data ss:Type=\"String\">" + p.Name + "</Data></Cell>");
}
else
break;
}
rowData.Append("</Row>");
foreach (T item in list)
{
rowData.Append("<Row>");
for (int x = 0; x < columnCount; x++) //each (PropertyInfo p in properties)
{
object o = properties[x].GetValue(item, null);
string value = o == null ? "" : o.ToString();
rowData.Append("<Cell ><Data ss:Type=\"String\">" + value + "</Data></Cell>");
}
rowData.Append("</Row>");
}
var sheet = @"<?xml version=""1.0""?>
<?mso-application progid=""Excel.Sheet""?>
<Workbook xmlns=""urn:schemas-microsoft-com:office:spreadsheet""
xmlns:o=""urn:schemas-microsoft-com:office:office""
xmlns:x=""urn:schemas-microsoft-com:office:excel""
xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet""
xmlns:html=""http://www.w3.org/TR/REC-html40"">
<DocumentProperties xmlns=""urn:schemas-microsoft-com:office:office"">
<Author>MSADMIN</Author>
<LastAuthor>MSADMIN</LastAuthor>
<Created>2011-07-12T23:40:11Z</Created>
<Company>Microsoft</Company>
<Version>12.00</Version>
</DocumentProperties>
<ExcelWorkbook xmlns=""urn:schemas-microsoft-com:office:excel"">
<WindowHeight>6600</WindowHeight>
<WindowWidth>12255</WindowWidth>
<WindowTopX>0</WindowTopX>
<WindowTopY>60</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID=""Default"" ss:Name=""Normal"">
<Alignment ss:Vertical=""Bottom""/>
<Borders/>
<Font ss:FontName=""Calibri"" x:Family=""Swiss"" ss:Size=""11"" ss:Color=""#000000""/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID=""s62"">
<Font ss:FontName=""Calibri"" x:Family=""Swiss"" ss:Size=""11"" ss:Color=""#000000"" ss:Bold=""1""/>
</Style>
</Styles>
<Worksheet ss:Name=""Sheet1"">
<Table ss:ExpandedColumnCount=""" + (properties.Count() + 1) + @""" ss:ExpandedRowCount=""" + (list.Count() + 1) + @""" x:FullColumns=""1"" x:FullRows=""1"" ss:DefaultRowHeight=""15"">
" + rowData.ToString() + @"
</Table>
<WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">
<PageSetup>
<Header x:Margin=""0.3""/>
<Footer x:Margin=""0.3""/>
<PageMargins x:Bottom=""0.75"" x:Left=""0.7"" x:Right=""0.7"" x:Top=""0.75""/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<HorizontalResolution>300</HorizontalResolution>
<VerticalResolution>300</VerticalResolution>
</Print>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveCol>2</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name=""Sheet2"">
<Table ss:ExpandedColumnCount=""1"" ss:ExpandedRowCount=""1"" x:FullColumns=""1"" x:FullRows=""1"" ss:DefaultRowHeight=""15"">
</Table>
<WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">
<PageSetup>
<Header x:Margin=""0.3""/>
<Footer x:Margin=""0.3""/>
<PageMargins x:Bottom=""0.75"" x:Left=""0.7"" x:Right=""0.7"" x:Top=""0.75""/>
</PageSetup>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name=""Sheet3"">
<Table ss:ExpandedColumnCount=""1"" ss:ExpandedRowCount=""1"" x:FullColumns=""1"" x:FullRows=""1"" ss:DefaultRowHeight=""15"">
</Table>
<WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">
<PageSetup>
<Header x:Margin=""0.3""/>
<Footer x:Margin=""0.3""/>
<PageMargins x:Bottom=""0.75"" x:Left=""0.7"" x:Right=""0.7"" x:Top=""0.75""/>
</PageSetup>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>";
System.Diagnostics.Debug.Print(StartTime.ToString() + " - " + DateTime.Now);
System.Diagnostics.Debug.Print((DateTime.Now - StartTime).ToString());
string attachment = "attachment; filename=Report.xls";
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", attachment);
HttpContext.Current.Response.Write(sheet);
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.End();
}
Thursday, 31 May 2012
What Are Generics In C# ???
Introduction
Generics Are Very Use Full Feature Provided By C# And Its Introduced In C# 2.0, Actually Generics Allow Us To Declare A Type Safe Data Structure Without Commuting Actual Data Type, Higher Performance And Quality Code.
Let Us Take An Example Of Stack
If We Are Making A Stack Then
Class Stack
{
}
Introduction
Generics Are Very Use Full Feature Provided By C# And Its Introduced In C# 2.0, Actually Generics Allow Us To Declare A Type Safe Data Structure Without Commuting Actual Data Type, Higher Performance And Quality Code.
Let Us Take An Example Of Stack
If We Are Making A Stack Then
Class Stack
{
}
Tuesday, 29 May 2012
Tuesday, 28 February 2012
Method To Convert A Number To String .
This Method Returns The String Corresponding To Integer Value Entered By The User
public static string NumberToWords(int number)
{
if (number == 0)
return "zero";
if (number < 0)
return "minus " + NumberToWords(Math.Abs(number));
string words = "";
if ((number / 1000000) > 0)
{
words += NumberToWords(number / 1000000) + " million ";
number %= 1000000;
}
if ((number / 1000) > 0)
{
words += NumberToWords(number / 1000) + " thousand ";
number %= 1000;
}
if ((number / 100) > 0)
{
words += NumberToWords(number / 100) + " hundred ";
number %= 100;
}
if (number > 0)
{
if (words != "")
words += "and ";
var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };
if (number < 20)
words += unitsMap[number];
else
{
words += tensMap[number / 10];
if ((number % 10) > 0)
words += "-" + unitsMap[number % 10];
}
}
return words;
}
Wednesday, 25 January 2012
Tuesday, 24 January 2012
Dynamic Menue With Event
Adding Dynamic Menue With Event
Dim ReportItem As New System.Windows.Forms.ToolStripLabel
AddHandler ReportItem.Click, AddressOf RunTimeToolStripMenuItemForReport_Click
AisStatusStrip1.Items.Add(ReportItem)
Event Method
Private Sub RunTimeToolStripMenuItemForReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
{}
Tuesday, 17 January 2012
How i Get 5th Highest Salary in sql server 2005
Create A table From Which 5th Highest Salary to be get
by using the command
create table employee ( code char(10),name varchar(200),sal float)
insert some values as
insert into employee values('1001','surender',20000)
insert into employee values('1002','dev',20000)
insert into employee values('1003','raj',25000)
insert into employee values('1004','narender',2000)
insert into employee values('1005','surender',50000)
insert into employee values('1006','surender',60000)
insert into employee values('1007','surender',70000)
insert into employee values('1008','surender',80000)
insert into employee values('1009','surender',90000)
insert into employee values('1010','surender',10000)
insert into employee values('1011','surender',5000)
insert into employee values('1012','surender',3000)
insert into employee values('1013','surender',7000)
insert into employee values('1014','surender',8000)
insert into employee values('1015','surender',9000)
getting all the salary in descending order
select * from employee order by sal desc
now to find top 5 th highest salary from employee table
select top 1 sal from
(
select distinct top 5 sal from employee order by sal desc
) a order by sal
Also We Can Make It General Query For Getting nth Highest Salary In Sql Server as
select top 1 sal from
{
select distinct top n sal from employee order by sal desc
} a order by sal
Monday, 2 January 2012
Concatenation of multiple rows of single column as a single data(row)
select Classcode,Classname,
(select subject from ClassSubjectList+',' as 'data()' from ClassSubject for xml path('')) as subject
from Class
where Classcode='LKG'
Friday, 30 December 2011
Tuesday, 27 December 2011
Sunday, 25 December 2011
Eval And Bind Methods For Asp.Net
The asp.net Eval() and Bind() expressions are heavily used in asp.net GridView and DetailsView data bound controls. The difference between these two is that Eval is used for read only purpose and Bind is used for read/edit purpose.
Syntax For Using :
<%# Eval("Variable")%>
Here Variable is the Name Of Parameter U Want to Pass...
Syntax For Using :
<%# Eval("Variable")%>
Here Variable is the Name Of Parameter U Want to Pass...
Subscribe to:
Posts (Atom)