Posted in C#, Uncategorized on December 5, 2007 | No Comments »
The goal here is to take advantage of C# 2.0 features as generics and create a reusable data layer capable of calling any stored procedure, with any sets of parameters and returning different sets of results.
The DataUtility class:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Collections.Generic;
using System.Data.SqlClient;
///
/// Summary description for DataUtility
///
namespace Data
{
[...]
Read Full Post »
Posted in .Net, ASP.Net, C#, Uncategorized on December 5, 2007 | No Comments »
Sometimes, there is a need to post a form from one page to another without any UI element. This is how to do it programmatically:
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(“FormElementName=” + formElementValue);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(http://somesite/somepage);
myRequest.Method = “POST”;
myRequest.ContentType = “application/x-www-form-urlencoded”;
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
Read Full Post »
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title>Untitled Page</title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<asp:ListBox ID=”LBSource” SelectionMode=”Multiple” runat=”server”>
<asp:ListItem Text=”Item1″ Value=”vItem1″></asp:ListItem>
<asp:ListItem Text=”Item2″ Value=”vItem2″></asp:ListItem>
<asp:ListItem Text=”Item3″ Value=”vItem3″></asp:ListItem>
<asp:ListItem Text=”Item4″ Value=”vItem4″></asp:ListItem>
<asp:ListItem Text=”Item5″ Value=”vItem5″></asp:ListItem>
</asp:ListBox>
<input type=”button” value=”Add” onclick=”moveItems(’<%= LBSource.ClientID %>‘, ‘<%= LBDestination.ClientID %>‘)” />
<input type=”button” value=”Remove” onclick=”moveItems(’<%= LBDestination.ClientID %>‘, ‘<%= LBSource.ClientID %>‘)” />
<asp:ListBox [...]
Read Full Post »
Posted in SQL, Uncategorized on October 25, 2007 | No Comments »
SELECT SomeColumn1 =
(
SELECT
CASE
WHEN SomeColumn3 IS NULL THEN ISNULL(SomeColumn3,”
ELSE ISNULL(SomeColumn4,”
END
FROM SomeTable2 WHERE SomeColumn5 = @SomeParameter2
)
FROM SomeTable1
WHERE SomeColumn2 = @SomeParameter1
Read Full Post »
Posted in SQL, Uncategorized on October 25, 2007 | No Comments »
INSERT SomeTable
(
@SomeColumn1,
@SomeColumn2
)
VALUES
(
@SomeParameter1,
@SomeParameter2
)
SELECT IDENT_CURRENT(‘SomeTable’ 
Read Full Post »
Posted in SQL, Uncategorized on October 25, 2007 | No Comments »
CREATE TABLE #TempTable
(
SomeColumn1 INT,
SomeColumn2 VARCHAR(50)
)
INSERT INTO #TempTable
SELECT SomeColumn3, SomeColumn4 FROM SomeTable WHERE SomeColumn5 = @SomeParameter
DROP TABLE #TempTable
Read Full Post »
Posted in SQL, Uncategorized on October 25, 2007 | No Comments »
DECLARE @Value
INSERT @Value = (SELECT SomeColumn1 FROM SomeTable WHERE SomeColumn2 = @SomeParameter)
Read Full Post »
Posted in Uncategorized on September 27, 2007 | No Comments »
C#
1. What is an abstract class?
2. What is the difference between an abstract class and an interface?
3. What is the access level for methods in an interface?
4. What is the difference between value types and reference types?
5. Is struct a value type or a reference type?
6. Is it possible to add a method to a [...]
Read Full Post »
Posted in XML, XSLT on October 11, 2006 | No Comments »
<xsl:for-each select=“MyNode“>
<MyNode>
<xsl:for-each select=“@*|*[not(* or @*)]“>
<xsl:attribute name=“{name(.)}“>
<xsl:value-of select=“.“/>
</xsl:attribute>
</xsl:for-each>
</MyNode>
</xsl:for-each>
Where MyNode:
<MyNode>value1</MyNode>
<MyNode>value2</MyNode>
<MyNode>value3</MyNode>
Read Full Post »
Posted in C#, Uncategorized on September 29, 2006 | No Comments »
C# Coding Standards here
Read Full Post »