DECLARE
@c varchar(4000),
@t varchar(128),
@maxchars int,
@fieldName varchar(100),
@dynamicSql nvarchar(2000)
SET @c = ''
SET @t='LEGACY_GMM'
SET @maxchars = 0
SET @fieldName = ''
SET @dynamicSql = ''
SELECT @c = @c + c.name + ', '
FROM syscolumns c
INNER JOIN sysobjects o ON o.id = c.id
WHERE o.name = 'LEGACY_GMM' and c.colorder < 101
while charindex(',', @c) > 0
begin
SET @fieldName = substring(@c,0,charindex(',',@c))
SET @dynamicSql = 'select max(len(' + @fieldName + ')) as ' + @fieldName + ' from LEGACY_GMM;'
execute sp_executesql @dynamicSql
SET @c = substring(@c, charindex(',',@c)+1, LEN(@c))
end
Wednesday, November 19, 2008
Thursday, August 14, 2008
Extender Controls
Extenders are basically controls that reach out and extend other controls.
For e.g. Validation controls, you can add RequiredfieldValidator to the page and associate it to a TextBox control, this extends the Textbox control and changes its behavior.
For e.g. Validation controls, you can add RequiredfieldValidator to the page and associate it to a TextBox control, this extends the Textbox control and changes its behavior.
Wednesday, August 13, 2008
Notes on ESB (Enterprise service Bus)
Here are few notes from the ESB talk from channel9.
What is ESB?
It is a solution, it is not a new product.
It utilizes SOA, software factory.
Why you need ESB? What value it brings?
ESB = Infrastructure,
- lot of services
- intelligent routing(sending message to different applications - all in runtime, there should be automatic subscription.)
- Dynamic transformation - what is the map?
Each application has to register to the ESB.
Security - WS* standards implemented in ESB so it is compatible with different vendors.
-Build functional service.
-It should react in short time i.e. it should be Agile, Agile also means one should not build from scratch, instead compose.
- one important thing, SOA is a means and not a goal.
ESB is enabler to SOA
Expose - Compose - Consume.
What is ESB?
It is a solution, it is not a new product.
It utilizes SOA, software factory.
Why you need ESB? What value it brings?
ESB = Infrastructure,
- lot of services
- intelligent routing(sending message to different applications - all in runtime, there should be automatic subscription.)
- Dynamic transformation - what is the map?
Each application has to register to the ESB.
Security - WS* standards implemented in ESB so it is compatible with different vendors.
-Build functional service.
-It should react in short time i.e. it should be Agile, Agile also means one should not build from scratch, instead compose.
- one important thing, SOA is a means and not a goal.
ESB is enabler to SOA
Expose - Compose - Consume.
What is an Architect?
Here are few notes from the Arcast talk.
What is an Architect?
1) An architect is a Designer.
Strength - Strong Software Engineering fundatmetal.
Functional Structure - software is nothing if it is not useful.
Beautiful - Solution that is pleasing to eyes.
Designer should have a great vision - one should study patterns and apply patterns
SOA + Single signon + integration pattern
WCF = service oriented platform + security + transaction.
2) An architect is an Advocate
He should Listen, observe, think strategically.
Listen to Customers, partners, users, developers.
3) An architect should be an Explorer
Looking for opportunity.
Heading into unknown.
Help business find technology solution to business problem.
as an explorer he has to a) Visionary: technology trends etc. b) Persuasive : Pro / cons of emerging trend. c) Accountable.
What is an Architect?
1) An architect is a Designer.
Strength - Strong Software Engineering fundatmetal.
Functional Structure - software is nothing if it is not useful.
Beautiful - Solution that is pleasing to eyes.
Designer should have a great vision - one should study patterns and apply patterns
SOA + Single signon + integration pattern
WCF = service oriented platform + security + transaction.
2) An architect is an Advocate
He should Listen, observe, think strategically.
Listen to Customers, partners, users, developers.
3) An architect should be an Explorer
Looking for opportunity.
Heading into unknown.
Help business find technology solution to business problem.
as an explorer he has to a) Visionary: technology trends etc. b) Persuasive : Pro / cons of emerging trend. c) Accountable.
Wednesday, August 6, 2008
Custome Site Map to build menus from Database instead of XML
We will use the database as shown in fig.
ID, ParentNodeID are integers
rest of the fields are string.

Make following entry in the web.config file.

Now create following class which implements the StaticSitemapProvider
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Specialized;
using System.Data.SqlClient;
using System.Security.Permissions;
///
/// Summary description for SqlSiteMapProvider
///
public class SqlSiteMapProvider : StaticSiteMapProvider
{
private SiteMapNode rootNode = null;
private SqlConnection sqlConnection = null;
private string sp = string.Empty;
// This string is case sensitive.
private string sqlConnectionStringName = "sqlSiteMapConnectionString";
// Implement a default constructor.
public SqlSiteMapProvider() { }
// Some basic state to help track the initialization state of the provider.
private bool initialized = false;
public virtual bool IsInitialized {
get {
return initialized;
}
}
// Return the root node of the current site map.
public override SiteMapNode RootNode {
get {
SiteMapNode temp = null;
temp = BuildSiteMap();
return temp;
}
}
protected override SiteMapNode GetRootNodeCore() {
return RootNode;
}
// Initialize is used to initialize the properties and any state that the
// SqlProvider holds, but is not used to build the site map.
// The site map is built when the BuildSiteMap method is called, it reads the values from the web.config
// in the attributes namevaluecollection.
public override void Initialize(string name, NameValueCollection attributes) {
if (IsInitialized)
return;
base.Initialize(name, attributes);
// Create and test the connection to the Microsoft Access database.
// Retrieve the Value of the Access connection string from the
// attributes NameValueCollection.
string connectionString = attributes[sqlConnectionStringName];
sp = attributes["storedProcedure"];
if (null == connectionString || connectionString.Length == 0)
throw new Exception("The connection string was not found.");
else
sqlConnection = new SqlConnection(connectionString);
initialized = true;
}
///
/// SiteMapProvider and StaticSiteMapProvider methods that this derived class must override.
///
// Clean up any collections or other state that an instance of this may hold.
protected override void Clear() {
lock (this) {
rootNode = null;
base.Clear();
}
}
// Build an in-memory representation from persistent
// storage, and return the root node of the site map.
public override SiteMapNode BuildSiteMap() {
int parentNodeId = 0;
// Since the SiteMap class is static, make sure that it is
// not modified while the site map is built.
lock(this) {
// If there is no initialization, this method is being
// called out of order.
if (! IsInitialized) {
throw new Exception("BuildSiteMap called incorrectly.");
}
// If there is no root node, then there is no site map.
if (null == rootNode) {
// Start with a clean slate
Clear();
// Select the root node of the site map from Microsoft Access.
int rootNodeId = -1;
if (sqlConnection.State == ConnectionState.Closed)
sqlConnection.Open();
SqlCommand rootNodeCommand = sqlConnection.CreateCommand();
rootNodeCommand.CommandText = sp;
rootNodeCommand.CommandType = CommandType.StoredProcedure;
SqlDataReader rootNodeReader = rootNodeCommand.ExecuteReader();
while( rootNodeReader.Read()) {
if (!rootNodeReader.IsDBNull(0))
{
rootNodeId = rootNodeReader.GetInt32(0);
}
// Create a SiteMapNode that references the current StaticSiteMapProvider.
if (rootNodeReader.IsDBNull(4))
{
rootNode = new SiteMapNode(this,
rootNodeId.ToString(),
rootNodeReader.GetString(1),
rootNodeReader.GetString(2),
rootNodeReader.GetString(3));
parentNodeId = rootNodeId;
}
else if (rootNodeReader.GetInt32(4) == parentNodeId)
{
SiteMapNode childNode = new SiteMapNode(this,
rootNodeId.ToString(),
rootNodeReader.GetString(1),
rootNodeReader.GetString(2),
rootNodeReader.GetString(3));
AddNode(childNode, rootNode);
}
else
{
SiteMapNode ch1 = new SiteMapNode(this,
rootNodeId.ToString(),
rootNodeReader.GetString(1),
rootNodeReader.GetString(2),
rootNodeReader.GetString(3));
SiteMapNode parent = FindSiteMapNodeFromKey(rootNodeReader.GetInt32(4).ToString());
AddNode(ch1,parent);
}
}
rootNodeReader.Close();
// Select the child nodes of the root node.
sqlConnection.Close();
}
return rootNode;
}
}
}
ID, ParentNodeID are integers
rest of the fields are string.
Make following entry in the web.config file.
Now create following class which implements the StaticSitemapProvider
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Specialized;
using System.Data.SqlClient;
using System.Security.Permissions;
///
/// Summary description for SqlSiteMapProvider
///
public class SqlSiteMapProvider : StaticSiteMapProvider
{
private SiteMapNode rootNode = null;
private SqlConnection sqlConnection = null;
private string sp = string.Empty;
// This string is case sensitive.
private string sqlConnectionStringName = "sqlSiteMapConnectionString";
// Implement a default constructor.
public SqlSiteMapProvider() { }
// Some basic state to help track the initialization state of the provider.
private bool initialized = false;
public virtual bool IsInitialized {
get {
return initialized;
}
}
// Return the root node of the current site map.
public override SiteMapNode RootNode {
get {
SiteMapNode temp = null;
temp = BuildSiteMap();
return temp;
}
}
protected override SiteMapNode GetRootNodeCore() {
return RootNode;
}
// Initialize is used to initialize the properties and any state that the
// SqlProvider holds, but is not used to build the site map.
// The site map is built when the BuildSiteMap method is called, it reads the values from the web.config
// in the attributes namevaluecollection.
public override void Initialize(string name, NameValueCollection attributes) {
if (IsInitialized)
return;
base.Initialize(name, attributes);
// Create and test the connection to the Microsoft Access database.
// Retrieve the Value of the Access connection string from the
// attributes NameValueCollection.
string connectionString = attributes[sqlConnectionStringName];
sp = attributes["storedProcedure"];
if (null == connectionString || connectionString.Length == 0)
throw new Exception("The connection string was not found.");
else
sqlConnection = new SqlConnection(connectionString);
initialized = true;
}
///
/// SiteMapProvider and StaticSiteMapProvider methods that this derived class must override.
///
// Clean up any collections or other state that an instance of this may hold.
protected override void Clear() {
lock (this) {
rootNode = null;
base.Clear();
}
}
// Build an in-memory representation from persistent
// storage, and return the root node of the site map.
public override SiteMapNode BuildSiteMap() {
int parentNodeId = 0;
// Since the SiteMap class is static, make sure that it is
// not modified while the site map is built.
lock(this) {
// If there is no initialization, this method is being
// called out of order.
if (! IsInitialized) {
throw new Exception("BuildSiteMap called incorrectly.");
}
// If there is no root node, then there is no site map.
if (null == rootNode) {
// Start with a clean slate
Clear();
// Select the root node of the site map from Microsoft Access.
int rootNodeId = -1;
if (sqlConnection.State == ConnectionState.Closed)
sqlConnection.Open();
SqlCommand rootNodeCommand = sqlConnection.CreateCommand();
rootNodeCommand.CommandText = sp;
rootNodeCommand.CommandType = CommandType.StoredProcedure;
SqlDataReader rootNodeReader = rootNodeCommand.ExecuteReader();
while( rootNodeReader.Read()) {
if (!rootNodeReader.IsDBNull(0))
{
rootNodeId = rootNodeReader.GetInt32(0);
}
// Create a SiteMapNode that references the current StaticSiteMapProvider.
if (rootNodeReader.IsDBNull(4))
{
rootNode = new SiteMapNode(this,
rootNodeId.ToString(),
rootNodeReader.GetString(1),
rootNodeReader.GetString(2),
rootNodeReader.GetString(3));
parentNodeId = rootNodeId;
}
else if (rootNodeReader.GetInt32(4) == parentNodeId)
{
SiteMapNode childNode = new SiteMapNode(this,
rootNodeId.ToString(),
rootNodeReader.GetString(1),
rootNodeReader.GetString(2),
rootNodeReader.GetString(3));
AddNode(childNode, rootNode);
}
else
{
SiteMapNode ch1 = new SiteMapNode(this,
rootNodeId.ToString(),
rootNodeReader.GetString(1),
rootNodeReader.GetString(2),
rootNodeReader.GetString(3));
SiteMapNode parent = FindSiteMapNodeFromKey(rootNodeReader.GetInt32(4).ToString());
AddNode(ch1,parent);
}
}
rootNodeReader.Close();
// Select the child nodes of the root node.
sqlConnection.Close();
}
return rootNode;
}
}
}
WEB PARTS
- Web Parts are objects in the Portal Framework which the end user can open, close, minimize, maximize, or move from one part of the page to another part.
- Portal Framework defines everything in terms of Zone, there are zones for laying out as well as for editing contents.
- Zones are managed by Framework manager control called WebPartManager.
- WebPartManager completely manages the state of the zones and the content palced in these zones on a per-user basis.
- WebPartManager can also manage the communications between different zones.
- WebPartManager has to be present on every page that works with portal framework, or you can place on the master page.
- Portal Framework defines everything in terms of Zone, there are zones for laying out as well as for editing contents.
- Zones are managed by Framework manager control called WebPartManager.
- WebPartManager completely manages the state of the zones and the content palced in these zones on a per-user basis.
- WebPartManager can also manage the communications between different zones.
- WebPartManager has to be present on every page that works with portal framework, or you can place on the master page.
Tuesday, August 5, 2008
XML- XSL
XML – Extensible Markup Language
XSL – Extensible Stylesheet Language
XSL is an XML based language for expressing stylesheets for manipulating XML data.
Xpath, a selection syntax allowing us to select nodes within an XML document. Xpath is used in XSLT to specify which nodes to use in a transformation, and for selecting XML content to include in an output document.
An XSLT stylesheet consists of a series of one or more templates, togather with instructions based on Xpath expressions that tell an XSLT processor how to match the templates against nodes in an XML input document. The result of applying template is another XML document, output could be HTML, or plain text also.
XSL – Extensible Stylesheet Language
XSL is an XML based language for expressing stylesheets for manipulating XML data.
Xpath, a selection syntax allowing us to select nodes within an XML document. Xpath is used in XSLT to specify which nodes to use in a transformation, and for selecting XML content to include in an output document.
An XSLT stylesheet consists of a series of one or more templates, togather with instructions based on Xpath expressions that tell an XSLT processor how to match the templates against nodes in an XML input document. The result of applying template is another XML document, output could be HTML, or plain text also.
Thursday, July 31, 2008
Friday, June 20, 2008
Reading resources from resource dll of another application
Copy the Application Dll and Resource dll to one folder.
in the code
Assembly assL = Assembly.LoadFrom(@"C:\Personal\CERT\70-528\MGohil.Services.Authentication.dll");
//here ApplicationTokens is the resource file i.e. ApplicationTokens.resx or ApplicationTokens.en-US.resx
ResourceManager rm = new ResourceManager("MGohil.Services.Authentication.ApplicationTokens", assL);
string t = rm.GetString("XYZ_Key");
in the code
Assembly assL = Assembly.LoadFrom(@"C:\Personal\CERT\70-528\MGohil.Services.Authentication.dll");
//here ApplicationTokens is the resource file i.e. ApplicationTokens.resx or ApplicationTokens.en-US.resx
ResourceManager rm = new ResourceManager("MGohil.Services.Authentication.ApplicationTokens", assL);
string t = rm.GetString("XYZ_Key");
Wednesday, June 18, 2008
Rename database table column SQL Server
Execute below statemnet in SQL analyzer and it will rename the column name.
exec sp_rename 'DBO.Customers.CompanyName', 'CorporateName', 'COLUMN'
exec sp_rename 'DBO.Customers.CompanyName', 'CorporateName', 'COLUMN'
Wednesday, June 11, 2008
ASP.NET Control Access Key, AssociatedControlID and Underline single character for access key
Create a local resource file for the corresponding page.
Make an entry in the resource file Name = lblUserNameResource1.Text
and Value = <U>U</U>sername:
and in the ASP.net page for the control use the meta tag instead of text
i.e. meta:resourcekey="lblUserNameResource1"
Make an entry in the resource file Name = lblUserNameResource1.Text
and Value = <U>U</U>sername:
and in the ASP.net page for the control use the meta tag instead of text
i.e. meta:resourcekey="lblUserNameResource1"
Thursday, June 5, 2008
Reading from Resources.dll in ASP.NET
Assembly ass = Assembly.LoadFrom(@"C:\CERT\70-528\TestAssembly\MGohil.Services.Authentication.resources.dll");
string strManRes = ass.GetManifestResourceNames()[0]; // use this to get the manifest resource, in next line
Stream str = ass.GetManifestResourceStream("MGohil.Services.Authentication.ApplicationTokens.en-US.resources");
ResourceReader r = new ResourceReader(str);
IDictionaryEnumerator id = r.GetEnumerator();
while (id.MoveNext())
{
Console.WriteLine(id.Key + " - " + id.Value);
}
string strManRes = ass.GetManifestResourceNames()[0]; // use this to get the manifest resource, in next line
Stream str = ass.GetManifestResourceStream("MGohil.Services.Authentication.ApplicationTokens.en-US.resources");
ResourceReader r = new ResourceReader(str);
IDictionaryEnumerator id = r.GetEnumerator();
while (id.MoveNext())
{
Console.WriteLine(id.Key + " - " + id.Value);
}
Subscribe to:
Posts (Atom)