.Net Needed Codes
DB (save using XML parameter)
C#,sql.Good method.
Stored Procedure
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_app_HonorsAwardsUpdate]
@XML ntext,
@UserId int
AS
BEGIN
Declare @NameofHonour1 varchar(100)
Declare @NameofHonour2 varchar(100)
Declare @NameofHonour3 varchar(100)
Declare @NameofHonour4 varchar(100)
Declare @NameofHonour5 varchar(100)
– calling the Sp for taking data from xml file
DECLARE @DocID INT
BEGIN TRAN
EXEC SP_XML_PREPAREDOCUMENT @DocID OUTPUT, @XML
SELECT
@NameofHonour1 = NameofHonour1,
@NameofHonour2 = NameofHonour2,
@NameofHonour3 = NameofHonour3,
@NameofHonour4 = NameofHonour4,
@NameofHonour5 = NameofHonour5
FROM
OPENXML (@DocID, ‘root/HonorsAwards’)
WITH
(
NameofHonour1 varchar(100)
,NameofHonour2 varchar(100)
,NameofHonour3 varchar(100)
,NameofHonour4 varchar(100)
,NameofHonour5 varchar(100)
)
UPDATE [dbo].[Applications]
SET
[NameofHonour1]=@NameofHonour1
,[NameofHonour2]=@NameofHonour2
,[NameofHonour3]=@NameofHonour3
,[NameofHonour4]=@NameofHonour4
,[NameofHonour5]=@NameofHonour5
where [UserID]=@UserId
SET NOCOUNT ON;
IF @@ERROR>0
BEGIN
ROLLBACK TRAN
END
ELSE
BEGIN
COMMIT TRAN
END
EXEC SP_XML_REMOVEDOCUMENT @DocID
END
============================================================
Business Layer – BLHonorsAwards
using System;
using System.Collections.Generic;
using System.Text;
namespace NSEPBusiness
{
public class BLHonorsAwards
{
#region Local Variables Declaration
private int intUserId;
private string strNameofHonour1;
private string strNameofHonour2;
private string strNameofHonour3;
private string strNameofHonour4;
private string strNameofHonour5;
NSEPDataAccess.DAHonorsAwards ObjHonorsAwards = new NSEPDataAccess.DAHonorsAwards();
#endregion
#region Properties
public int IntUserId
{
get { return intUserId; }
set { intUserId = value; }
}
public string StrNameofHonour1
{
get { return strNameofHonour1; }
set { strNameofHonour1 = value; }
}
public string StrNameofHonour2
{
get { return strNameofHonour2; }
set { strNameofHonour2 = value; }
}
public string StrNameofHonour3
{
get { return strNameofHonour3; }
set { strNameofHonour3 = value; }
}
public string StrNameofHonour4
{
get { return strNameofHonour4; }
set { strNameofHonour4 = value; }
}
public string StrNameofHonour5
{
get { return strNameofHonour5; }
set { strNameofHonour5 = value; }
}
#endregion
#region CreateXML
public string CreateXml()
{
StringBuilder xml = new StringBuilder();
try
{
xml.Append(“<root><HonorsAwards NameofHonour1=\”");
xml.Append(StrNameofHonour1);
xml.Append(“\” NameofHonour2=\”");
xml.Append(StrNameofHonour2);
xml.Append(“\” NameofHonour3=\”");
xml.Append(StrNameofHonour3);
xml.Append(“\” NameofHonour4=\”");
xml.Append(StrNameofHonour4);
xml.Append(“\” NameofHonour5=\”");
xml.Append(StrNameofHonour5);
xml.Append(“\”/></root>”);
return (xml.ToString());
}
catch (Exception err)
{
throw err;
}
}
#endregion
#region Update HonorsAwards
public void Save()
{
ObjHonorsAwards.SaveRegistration(CreateXml(), IntUserId);
}
#endregion
}
}
=========================================================
DataAccessLayer – DLHonorsAwards
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using System.Configuration;
namespace NSEPDataAccess
{
public class DAHonorsAwards
{
string connectionString = @”server=192.168.0.235\SQLExpress;database=NSEP_05June07;uid=sa;pwd=assyst;”;
public int SaveRegistration(string strXml, int userId)
{
SqlParameter[] sqlParam = new SqlParameter[2];
sqlParam[0] = new SqlParameter(“@XML”, strXml);
sqlParam[1] = new SqlParameter(“@userId”, userId);
int inserted = 0;
inserted = (int)SqlHelper.ExecuteNonQuery(connectionString, “p_app_HonorsAwardsUpdate”, sqlParam);
return inserted;
}
}
}
Presentation Layer – HonorsAwards
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
public partial class HonorsAwards : System.Web.UI.Page
{
NSEPBusiness.BLHonorsAwards objHonorsAwards = new NSEPBusiness.BLHonorsAwards();
protected void Page_Load(object sender, EventArgs e)
{
}
#region Methods
public void AddHonorsAwards()
{
objHonorsAwards.IntUserId = 191;
objHonorsAwards.StrNameofHonour1 = txtNameofHonour1.Text;
objHonorsAwards.StrNameofHonour2 = txtNameofHonour2.Text;
objHonorsAwards.StrNameofHonour3 = txtNameofHonour3.Text;
objHonorsAwards.StrNameofHonour4 = txtNameofHonour4.Text;
objHonorsAwards.StrNameofHonour5 = txtNameofHonour5.Text;
}
#endregion
protected void btnSubmitRegistration_Click(object sender, EventArgs e)
{
AddHonorsAwards();
objHonorsAwards.Save();
}
}
C# numeric key,SPLIT FUNCTION SAMPLES
private void txtScore_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
base.OnKeyPress(e);
}
==================================== SPLIT FUNCTION
string abc = “sdaffaf,asdad”;
abc = abc.Split(‘,’).GetValue(0).ToString();
====================================
C# call sp + parameters and [Con-"using keyword"] SAMPLE
==========================================
public void fnSpExec()
{
//execute Sp for exporting Query output to an external filename given.
using (SqlConnection con = new SqlConnection(strConnect))
{
try
{
SqlCommand command = new SqlCommand(“Proc_DumpOutput”, con);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter(“@StrRights”, SqlDbType.VarChar, 4000, “StrRights”));
command.Parameters.Add(new SqlParameter(“@FullFileName”, SqlDbType.NChar, 50, “FullFileName”));
command.Parameters[0].Value = “name”;
command.Parameters[1].Value = ConfigurationManager.AppSettings["FullPath"];
con.Open();
command.ExecuteNonQuery();
con.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message, “Sql Connection Error”);
}
}
}
GENERALIZED Datatable to Httml ,saving using file stream samples =================
public static string ConvertToHtmlFile(DataTable sentDataTable)
{
// Check if the Sent DataTable is not empty or a Null
if (sentDataTable == null)
{
throw new System.ArgumentNullException(“sentDataTable”);
}
//Get a worker object.
StringBuilder StrBuilder = new StringBuilder();
//Open tags and write the top portion.
StrBuilder.Append(“<html xmlns=’http://www.w3.org/1999/xhtml’>”);
StrBuilder.Append(“<head>”);
StrBuilder.Append(“<title>”);
StrBuilder.Append(System.Configuration.ConfigurationSettings.AppSettings["Subject"].ToString() );
StrBuilder.Append(” : Page – “);
StrBuilder.Append(Guid.NewGuid().ToString());
StrBuilder.Append(“</title>”);
StrBuilder.Append(“</head>”);
StrBuilder.Append(“<body>”);
StrBuilder.Append(System.Configuration.ConfigurationSettings.AppSettings["Subject"].ToString().ToUpper() + ” AS ON ” + DateTime.Today.ToString(“MM/dd/yyyy”));
StrBuilder.Append(“<br> </br>”);
StrBuilder.Append(“<table border=’1px’ cellpadding=’5′ cellspacing=’0′ “);
StrBuilder.Append(“style=’border: solid 1px Silver; font-size: x-small;’>”);
//Add the headings row.
StrBuilder.Append(“<tr align=’left’ valign=’top’>”);
foreach (DataColumn DtColumn in sentDataTable.Columns)
{
StrBuilder.Append(“<td align=’middle’ valign=’top’ style=\”background-color: LightGrey\”>”);
StrBuilder.Append(DtColumn.ColumnName);
StrBuilder.Append(“</td>”);
}
StrBuilder.Append(“</tr>”);
//Add the data rows.
foreach (DataRow DtRow in sentDataTable.Rows)
{
StrBuilder.Append(“<tr align=’left’ valign=’top’>”);
foreach (DataColumn myColumn in sentDataTable.Columns)
{
StrBuilder.Append(“<td align=’left’ valign=’top’>”);
StrBuilder.Append(DtRow[myColumn.ColumnName].ToString());
StrBuilder.Append(“</td>”);
}
StrBuilder.Append(“</tr>”);
}
//Close tags.
StrBuilder.Append(“</table>”);
StrBuilder.Append(“</body>”);
StrBuilder.Append(“</html>”);
return StrBuilder.ToString();
}
=****===========****===========****==========
private static void GetHtmlData()
{
using (SqlConnection sConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["SqlConnect"].ToString()))
{
try
{
string strText = “select * from test”;
SqlDataAdapter DA = new SqlDataAdapter ( strText, sConnection );
// initialize dataset object
DataTable DtData = new DataTable();
DA.Fill(DtData);
string StrHtml = ConvertToHtmlFile(DtData);
FileStream Fstr = new FileStream(“PendingFinesReport.html”, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(Fstr);
////// Write to the file using StreamWriter class
m_streamWriter.WriteLine(StrHtml);
m_streamWriter.Flush();
Fstr.Close();
Console.WriteLine(“File Written”);
}
catch (Exception)
{
Console.WriteLine(“Database Error, Cannot Create File”);
}
}
}
Mial c# + (Appconfig settings),APP UPDATION SAMPLES
using System.Net.Mail;
public static void SendEmail()
{
try
{
MailMessage NewMessage = new MailMessage();
string strEmailID = System.Configuration.ConfigurationSettings.AppSettings["FromID"].ToString();
NewMessage.From = new MailAddress(strEmailID);
SqlConnection sConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["SqlConnect"].ToString());
sConnection.Open();
string strText = “select distinct email=rtrim(ltrim(emailid)) from sample”;
SqlCommand sCommand = new SqlCommand(strText, sConnection);
sCommand.CommandType = CommandType.Text;
SqlDataReader sReader = sCommand.ExecuteReader();
while (sReader.Read())
{
//foreach (MailAddress ma in NewMessage.To)
//{
NewMessage.To.Add(new MailAddress(sReader["Email"].ToString()));
//}
}
//}
sReader.Close();
sConnection.Close();
NewMessage.Subject = System.Configuration.ConfigurationSettings.AppSettings["Subject"];
NewMessage.Body = System.Configuration.ConfigurationSettings.AppSettings["Body"];
string strPath = System.Configuration.ConfigurationSettings.AppSettings[@"FullPath"];
Attachment attachFile = new Attachment(strPath);
NewMessage.Attachments.Add(attachFile);
NewMessage.IsBodyHtml = true;
SmtpClient Client = new SmtpClient();
Client.Send(NewMessage);
Console.WriteLine(“Mail send Successfully”);
}
catch (Exception)
{
Console.WriteLine(“SMTP error”);
}
}
==============================
==============================Appconfig
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<appSettings>
<add key=”SqlConnect” value=”Data Source=Server1;Initial Catalog=sample;User ID=sa;Password=sa;” />
<add key=”FromID” value=”AUTOMATED_MAIL@sample.com” />
<add key=”Subject” value=”Subject” />
<add key=”Body” value=”Body” />
<add key=”FullPath” value=”c:\PendingDues.csv” />
</appSettings>
<system.net>
<mailSettings>
<smtp>
<network host=”xxx.xxx.x.xx” defaultCredentials=”true”/>
</smtp>
</mailSettings>
</system.net>
</configuration>
==============================================
Update AppConfig c# ,by Key
=============================
public void UpdateConfigKey(string strKey, string newValue)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load (Assembly.GetExecutingAssembly().Location + “.config”);
XmlNode appSettingsNode =
xmlDoc.SelectSingleNode(“configuration/appSettings”);
// Attempt to locate the requested setting.
foreach (XmlNode childNode in appSettingsNode)
{
if (childNode.Attributes["key"].Value == strKey)
childNode.Attributes["value"].Value = newValue;
}
xmlDoc.Save(Assembly.GetExecutingAssembly().Location + “.config”);
}
=========================================================================
XML Spread sheet .Net
public static string getContentInXML(System.Data.DataTable dt)
{
string Excelcontent = string.Empty;
StringBuilder content = new StringBuilder();
content.Length = 0;
string Coltype = string.Empty;
content.Append(“<?xml version=\”1.0\”?>”);
content.AppendLine();
content.Append(“<?mso-application progid=\”Excel.Sheet\”?>”);
content.AppendLine();
content.Append(“<Workbook xmlns=\”urn:schemas-microsoft-com:office:spreadsheet\” xmlns:ss=\”urn:schemas-microsoft-com:office:spreadsheet\”>”);
content.AppendLine();
//– Style to format Date Fields————-
content.Append(“<Styles>”);
content.AppendLine();
content.Append(“<Style ss:ID=\”DateTime\”>”);
content.AppendLine();
content.Append(“<NumberFormat ss:Format=\”mm/dd/yyyy;@\” />”);
content.AppendLine();
content.Append(” </Style>”);
content.AppendLine();
content.Append(” </Styles>”);
content.AppendLine();
//——————————————-
content.Append(” <Worksheet ss:Name=\”Sheet1\”>”);
content.AppendLine();
content.Append(” <ss:Table>”);
content.AppendLine();
content.Append(” <ss:Row>”);
content.AppendLine();
//Create the Column Names (Headings) Row
foreach (DataColumn dcs in dt.Columns)
{
content.Append(“<ss:Cell>”);
content.AppendLine();
content.Append(“<ss:Data ss:Type=\”String\”>” + dcs.ColumnName.ToString() + “</ss:Data>”);
content.AppendLine();
content.Append(“</ss:Cell>”);
content.AppendLine();
}
content.Append(” </ss:Row>”);
content.AppendLine();
//Generate the Content Rows
foreach (DataRow dr in dt.Rows)
{
content.Append(” <ss:Row>”);
content.AppendLine();
foreach (DataColumn dc in dt.Columns)
{
Coltype = dc.DataType.Name;
if (Coltype == “Int32″)
Coltype = “Number”;
else if (Coltype == “DateTime”)
Coltype = “DateTime”;
if (Coltype == “DateTime”) //— Format the cell if it’s of type DateTime
{
content.Append(“<ss:Cell ss:StyleID=\”DateTime\”>”);
content.AppendLine();
content.Append(“<ss:Data ss:Type=\”" + Coltype + “\”>” + string.Format(“{0:s}”, dr[dc.ColumnName]) + “</ss:Data>”);
}
else //— Format the Cell with “Number” or “String”
{
content.Append(“<ss:Cell>”);
content.AppendLine();
content.Append(“<ss:Data ss:Type=\”" + Coltype + “\”>” + dr[dc.ColumnName].ToString() + “</ss:Data>”);
}
content.AppendLine();
content.AppendLine();
content.Append(“</ss:Cell>”);
}
content.Append(” </ss:Row>”);
content.AppendLine();
}
content.Append(” </ss:Table>”);
content.AppendLine();
content.Append(” </Worksheet>”);
content.AppendLine();
content.Append(” </Workbook>”);
content.AppendLine();
Excelcontent = content.ToString();
return Excelcontent;
}
Export asc sv
public static string getContentInCSV(DataTable dt)
{
string ExcelContent=string.Empty;
string temp=string.Empty;
if (dt.Rows.Count > 0)
{
StringBuilder content = new StringBuilder();
content.Length = 0;
//Create the Column Names (Headings) Row
foreach (DataColumn dcs in dt.Columns)
{
content.Append(dcs.ColumnName.ToString() + “,”);//remove the last “,”
}
content.Remove(content.Length – 1, 1);
content.AppendLine();
//Generate the Content Rows
foreach (DataRow dr in dt.Rows)
{
foreach (DataColumn dc in dt.Columns)
{
temp=dr[dc.ColumnName].ToString();
temp=temp.Replace(‘,’,'-’);
content.Append(temp + “,”);
}
content.Remove(content.Length – 1, 1);//remove the last “,”
content.AppendLine();
}
ExcelContent = content.ToString();
}
return ExcelContent;
}
on new forms Page Load
if (contentType == “CSV”)
{
content=GreySites.Utilities.ExcelHandler.getContentInCSV(dt);
Response.ClearContent();
Response.AppendHeader(“Content-Disposition”, “attachment;filename=” + filename + “.csv”);
Response.ContentType = “text/CSV”;
Response.Write(content);
}
else
{
content = GreySites.Utilities.ExcelHandler.getContentInXML(dt);
Response.ClearContent();
Response.AppendHeader(“Content-Disposition”, “attachment;filename=” + filename + “.xml”);
Response.ContentType = “text/xml”;
Response.Write(content);
}
===============================================================
Done xml update insert delete
=============================
Xquery
|
Products.xml <?xml version=”1.0″ standalone=”yes”?> <NewDataSet> <Table> <ItemID>1</ItemID> <UserID>1</UserID> <ProductName>SOAP</ProductName> <Price>50</Price> </Table> <Table> <ItemID>2</ItemID> <UserID>2</UserID> <ProductName>BOOK</ProductName> <Price>40</Price> </Table> <Table> <ItemID>3</ItemID> <UserID>3</UserID> <ProductName>PEN</ProductName> <Price>50</Price> </Table> <Table> <ItemID>4</ItemID> <UserID>5</UserID> <ProductName>PENCIL</ProductName> <Price>50</Price> </Table> </NewDataSet> |
Users.xml <?xml version=”1.0″ standalone=”yes”?> <NewDataSet> <Table> <userId>1</userId> <firstName>Sunil</firstName> <lastName>krishna</lastName> <companyName>Assyst</companyName> </Table> <Table> <userId>2</userId> <firstName>JOMY</firstName> <lastName>krishna</lastName> <companyName>Assyst</companyName> </Table> <Table> <userId>3</userId> <firstName>ANAS</firstName> <lastName>krishna</lastName> <companyName>Assyst</companyName> </Table> <Table> <userId>4</userId> <firstName>Aneesh</firstName> <lastName> </lastName> <companyName> </companyName> </Table> </NewDataSet> |
Dim col As New XQueryNavigatorCollection()
col.AddNavigator(“tbl_users.xml”, “Users”)
col.AddNavigator(“Products.xml”, “Products”)
Dim ds As New DataSet
Dim query_outer As String
Dim query_innerjoin As String
Dim doc2 As New XmlDocument
query_innerjoin = “for $u in document(“”Users”")//Table , $p in document(“”Products”")//Table “ & _
“where $u/userId = $p/UserID “ & _
“return <li> {$u/firstName , $p/ProductName} </li> “ ””inner join
Dim expr As New XQueryExpression(query_innerjoin)
Dim rawXML As String = “<Results> “ & (expr.Execute(col)).ToXml() & ” </Results> “
””Outer join in hierrarichial view style
query_outer = “for $p in document(“”Products”")//Table “ & _
“return <Product> {$p/ProductName} “ & _
“{ for $u in document(“”Users”")//Table “ & _
” where $p/UserID =$u/userId “ & _
“return <user> {$p/ProductName} {$u/firstName} </user> } </Product> “
””Outer join in normal style
query_outer = “for $p in document(“”Products”")//Table “ & _
“return <Product> {$p/ProductName} “ & _
“{ for $u in document(“”Users”")//Table “ & _
” where $p/UserID =$u/userId “ & _
“return $u/firstName } </Product> “
Dim expr1 As New XQueryExpression(query_outer)
Dim rawXML1 As String = “<Results> “ & (expr1.Execute(col)).ToXml() & ” </Results> “
doc2.LoadXml(rawXML1)
ds.ReadXml(New XmlNodeReader(doc2))
GridData.DataSource = ds
ADD ROW IN XML
Dim ds As New DataSet
strpath = “tbl_users.xml”
xmlDoc.Load(strpath)
Dim row As XmlNode = xmlDoc.SelectSingleNode(“NewDataSet/Table[userId='2']“)
Dim parent As XmlNode = xmlDoc.SelectSingleNode(“NewDataSet/Table[userId='2']“).ParentNode
row = row.CloneNode(True) ” make a copy of the node by cloning it
row.SelectSingleNode(“userId”).InnerText = parent.ChildNodes.Count + 1
row(“firstName”).InnerText = TxtBox2.Text ” set the new values of the row’s fields
row(“lastName”).InnerText = TxtBox3.Text
row(“companyName”).InnerText = TxtBox4.Text
row(“userName”).InnerText = TxtBox4.Text
row(“password”).InnerText = TxtBox5.Text
” append the cloned row to the parent node
parent.AppendChild(row)
TxtBox1.Text = parent.ChildNodes.Count
xmlDoc.Save(strpath)
ds.ReadXml(strpath)
GridData.DataSource = ds
UPDATION IN XML
Dim loNode As XmlNode
xmlDoc.Load(strpath)
Dim intId As Integer
intId = GridData.Selected.Rows(0).Cells(0).Text
TxtBox1.Text = intId
loNode = xmlDoc.SelectSingleNode(“NewDataSet/Table[userId='" & TxtBox1.Text & "']“)
loNode(“userId”).InnerText = Val(TxtBox1.Text)
loNode(“firstName”).InnerText = TxtBox2.Text ” set the new values of the row’s fields
loNode(“lastName”).InnerText = TxtBox3.Text
loNode(“companyName”).InnerText = TxtBox4.Text
loNode(“userName”).InnerText = TxtBox4.Text
loNode(“password”).InnerText = TxtBox5.Text
‘ ”Dim x = xmlDoc.GetElementsByTagName(“lastName”)
‘ ”MsgBox(loNode.InnerText)
‘ ”For i = 1 To x.Count – 1
‘ ” MsgBox(x.Item(i).InnerText)
‘ ”Next
xmlDoc.Save(strpath)
ds.ReadXml(strpath)
GridData.DataSource = ds
DELETION IN XML
strpath = “tbl_users.xml”
Dim ds As New DataSet
With GridData
Dim intId As Integer
intId = .Selected.Rows(0).Cells(0).Text
xmlDoc.Load(strpath)
Dim row As XmlNode = xmlDoc.SelectSingleNode(“NewDataSet/Table[userId='" & intId & "']“)
row.ParentNode.RemoveChild(row)
xmlDoc.Save(strpath)
ds.ReadXml(strpath)
GridData.DataSource = ds
End With
XML ENCRYPTION
Dim xmldoc As New XmlDocument()
Try
xmldoc.Load(“D:\Aneesh k\xsl-test project\ToEncrypt.xml”)
‘xmldoc.Load(“D:\ToQuery.xml”)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Dim tDESkey As New TripleDESCryptoServiceProvider()
Dim sElem As XmlElement = CType(xmldoc.SelectSingleNode(“/NewDataSet”), XmlElement)
Dim exml As EncryptedXml = New EncryptedXml(xmldoc)
Dim encryptedArray As Byte() = exml.EncryptData(sElem, tDESkey, False)
Dim ed As New EncryptedData()
ed.Type = EncryptedXml.XmlEncElementUrl
ed.EncryptionMethod = New EncryptionMethod(EncryptedXml.XmlEncTripleDESUrl)
ed.CipherData = New CipherData()
ed.CipherData.CipherValue = encryptedArray
EncryptedXml.ReplaceElement(sElem, ed, True)
xmldoc.Save(“D:\Aneesh k\xsl-test project\encrypted.xml”)
Dim encryptedDoc As New XmlDocument()
encryptedDoc.Load(“D:\Aneesh k\xsl-test project\encrypted.xml”)
Dim encryptedElement As XmlElement = CType(encryptedDoc.GetElementsByTagName(“EncryptedData”)(0), XmlElement)
Dim ed2 As New EncryptedData()
ed2.LoadXml(encryptedElement)
Dim exml2 As New EncryptedXml()
Dim decryptedBilling As Byte() = exml2.DecryptData(ed2, tDESkey)
MsgBox(tDESkey.ToString)
exml2.ReplaceData(encryptedElement, decryptedBilling)
encryptedDoc.Save(“D:\Aneesh k\xsl-test project\Decrypted.xml”)
End Sub
XSL
New1.xsl
<?xml version=”1.0″ encoding=”ISO-8859-1″?><xsl:stylesheet version=”1.0″
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”><xsl:template match=”/”>
<html>
<body>
<h2>USER LIST</h2>
<table border=”1″ Cellalign=”center”>
<tr bgcolor=”#9acd32″>
<th align=”left”>firstName</th>
<th align=”left”>lastName</th>
<th align=”left”>companyName</th>
<th align=”left”>emailAddress</th>
<th align=”left”>userName</th>
<th align=”left”>password</th>
<th align=”left”>createdDate</th>
<th align=”left”>createdBy</th>
<th align=”left”>status</th>
<th align=”left”>secretQuestion</th>
<th align=”left”>secretAnswer</th>
</tr>
<xsl:for-each select=”NewDataSet/Table”>
<tr>
<td><xsl:value-of select=”firstName”/></td>
<td><xsl:value-of select=”lastName”/></td>
<td><xsl:value-of select=”companyName”/></td>
<td><xsl:value-of select=”emailAddress”/></td>
<td><xsl:value-of select=”userName”/></td>
<td><xsl:value-of select=”password”/></td>
<td><xsl:value-of select=”createdDate”/></td>
<td><xsl:value-of select=”createdBy”/></td>
<td><xsl:value-of select=”status”/></td>
<td><xsl:value-of select=”secretQuestion”/></td>
<td><xsl:value-of select=”secretAnswer”/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>
New.xml
<?xml version=”1.0″ standalone=”yes”?>
<?xml-stylesheet type=”text/xsl” href=”new1.xsl”?>
<NewDataSet>
<Table>
<userId>101</userId>
<firstName>aaa</firstName>
<lastName>fff</lastName>
<companyName>xxx</companyName>
<emailAddress>k.kkk@ppp</emailAddress>
.
.
.
Wb1.Navigate(“D:\Aneesh k\xsl-test project\new.xml”)
“””””””Stored procedure encryption
declare @encryptedstuff VARCHAR(100)
declare @MYText VARCHAR(100)
declare @decryptedstuff VARCHAR(100)
SET @MYText = ‘ANEESH KUZHIKKATTIL’
SET @encryptedstuff = EncryptByPassPhrase(‘LED_PWD-2007′, @MYText)
SELECT @encryptedstuff
SET @decryptedstuff = DecryptByPassPhrase(‘LED_PWD-2007′, @encryptedstuff)
SELECT @decryptedstuff
Hello world!
Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!
-
Archives
- June 2009 (2)
- April 2009 (2)
- August 2008 (2)
- July 2008 (9)
- June 2008 (10)
- May 2008 (1)
- March 2008 (1)
- December 2007 (2)
-
Categories
-
RSS
Entries RSS
Comments RSS