SqlConnection con=new SqlConnection (ConfigurationManager.ConnectionStrings["kumarConnectionString"].ConnectionString);
protected void Button1_Click1(object sender, EventArgs e)
{
DataSet ds = new DataSet();
string firstSql = null;
//connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password";
firstSql = "select * from emp;";
firstSql += "select * from dep";
try
{
SqlCommand cmd = new SqlCommand(firstSql, con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(ds);
//creating data relations
DataRelation relation;
DataColumn table1Column;
DataColumn table2Column;
//retrieve column
table1Column = ds.Tables[0].Columns[0];
table2Column = ds.Tables[1].Columns[0];
//relating tables
relation = new DataRelation("relation", table1Column, table2Column);
//assign relation to dataset
ds.Relations.Add(relation);
Response.Write("Data relation completed");
}
catch (Exception ex)
{
Response.Write("Can not open con ! ");
}
}
Friday, December 17, 2010
Reading Xml file and fill dropdown....
XmlNode eleDestNodeLists;
string FilePath = Request.PhysicalApplicationPath + @"Configuration\" + "UserInfo.xml";
XmlDocument docSource = new XmlDocument();
docSource.Load(FilePath);
Int32 assetid = Convert.ToInt32(Session["assetid"].ToString());
string sbookCode = Session["bookCode"].ToString();
eleDestNodeLists = docSource.SelectSingleNode("/UserInfo/Asset[@assetid='" + assetid + "' and @BookCode='" + sbookCode.ToString() + "']");
foreach (XmlNode xn in eleDestNodeLists.ChildNodes)
{
string abbreviation = xn.Attributes.GetNamedItem("abbreviation").Value;
string id = xn.Attributes["id"].Value;
ddlRole.Items.Add(new ListItem(abbreviation, id));
Page.ClientScript.RegisterStartupScript(typeof(Page), "FillUserName", "setTimeout(\"FillUserName()\",1000);", true);
}
string FilePath = Request.PhysicalApplicationPath + @"Configuration\" + "UserInfo.xml";
XmlDocument docSource = new XmlDocument();
docSource.Load(FilePath);
Int32 assetid = Convert.ToInt32(Session["assetid"].ToString());
string sbookCode = Session["bookCode"].ToString();
eleDestNodeLists = docSource.SelectSingleNode("/UserInfo/Asset[@assetid='" + assetid + "' and @BookCode='" + sbookCode.ToString() + "']");
foreach (XmlNode xn in eleDestNodeLists.ChildNodes)
{
string abbreviation = xn.Attributes.GetNamedItem("abbreviation").Value;
string id = xn.Attributes["id"].Value;
ddlRole.Items.Add(new ListItem(abbreviation, id));
Page.ClientScript.RegisterStartupScript(typeof(Page), "FillUserName", "setTimeout(\"FillUserName()\",1000);", true);
}
Thursday, December 16, 2010
Importanat Question
What is Application Blocks?
What are the processes to implement the strong name in the assembly?
How to use Memory management in .Net?
What is serialization in .NET? What are the ways to control serialization?
if there are two version of assembly is installed in computer the how we decide that which is using ?
Ans-- Assembly information is stored in manifest, there are 4 version of assembly (major, minor, build and revision) so we can decide the version through major and minor minor like 2.0.--.—
What is the difference between the application and caching?
what is assembly placement?
What are three test cases you should go through in unit testing?
Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).
What are possible implementations of distributed applications in .NET?
What is the consideration in deciding to use .NET Remoting or ASP.NET Web Services?
What security measures exist for .NET Remoting in System.Runtime.Remoting?
None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.
What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.
Can you configure a .NET Remoting object via XML file?
Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.
Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
Inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things. When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request to the actual worker process aspnet_wp.exe.
What namespace does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page
What are the processes to implement the strong name in the assembly?
How to use Memory management in .Net?
What is serialization in .NET? What are the ways to control serialization?
if there are two version of assembly is installed in computer the how we decide that which is using ?
Ans-- Assembly information is stored in manifest, there are 4 version of assembly (major, minor, build and revision) so we can decide the version through major and minor minor like 2.0.--.—
What is the difference between the application and caching?
what is assembly placement?
What are three test cases you should go through in unit testing?
Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).
What are possible implementations of distributed applications in .NET?
What is the consideration in deciding to use .NET Remoting or ASP.NET Web Services?
What security measures exist for .NET Remoting in System.Runtime.Remoting?
None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.
What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.
Can you configure a .NET Remoting object via XML file?
Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.
Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
Inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things. When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request to the actual worker process aspnet_wp.exe.
What namespace does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page
Labels:
Importanat Question
Friday, December 10, 2010
Update Existing Xml and If Xml is not created it will create and then update the Existing Xml...
static public void MoveUserInfo(string destFolder)
{
string _sourcePath = "";
string _configurationPath = "";
_sourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "UserInfo.xml");
_configurationPath = Path.Combine(Path.Combine(destFolder, "Configuration"), "UserInfo.xml");
if (!Directory.Exists(Path.Combine(destFolder, "Configuration")))
Directory.CreateDirectory(Path.Combine(destFolder, "Configuration"));
if (File.Exists(_configurationPath) == true)
{
updateUserInfoXML(_sourcePath, _configurationPath);
}
else //Create UserInfo.Xml file into Directory if not Exist in the Destination Path..
{
File.Copy(_sourcePath, _configurationPath, true);
}
}
static public void updateUserInfoXML(string pathSource, string pathDestination)
{
try
{
XmlDocument docSource = new XmlDocument();
XmlDocument docDestination = new XmlDocument();
string xmlMmessage = "";
docSource.Load(pathSource);
docDestination.Load(pathDestination);
XmlNodeList elemList = docSource.GetElementsByTagName("Asset");
//XmlNodeList elemListRoll = docSource.GetElementsByTagName("role");
//XmlNodeList elemListUser = docSource.GetElementsByTagName("User");
string attrAssetID;
XmlNodeList eleDestNodeList;
XmlNode eleDestinationNode = docDestination.DocumentElement;
foreach (XmlNode eleSourceNode in elemList)
{
attrAssetID = eleSourceNode.Attributes["assetid"].Value;
// attrRollID = eleSourceNode.Attributes["rollid"].Value;
//attrUserID = eleSourceNode.Attributes["Userid"].Value;
eleDestNodeList = docDestination.SelectNodes("/UserInfo/Asset[@assetid='" + attrAssetID.ToString() + "']");
if (eleDestNodeList.Count > 0)
{
eleDestinationNode = docDestination.SelectSingleNode("/UserInfo/Asset[@assetid='" + attrAssetID.ToString() + "']");
//docSource.AppendChild()
//---IF NODE EXISTS THEN REPLACE THE SOURCE NODE WITH TARGET NODE
XmlDocumentFragment fragment = docDestination.CreateDocumentFragment();
fragment.InnerXml = eleSourceNode.OuterXml;
eleDestinationNode.ParentNode.ReplaceChild(fragment, eleDestinationNode);
xmlMmessage = "Sucessfully replaced";
}
else
{
//---IF NODE IS NOT EXISTS THEN APPEND THE SOURCE NODE WITH TARGET NODE
XmlDocumentFragment fragment = docDestination.CreateDocumentFragment();
fragment.InnerXml = eleSourceNode.OuterXml;
eleDestinationNode.AppendChild(fragment);
xmlMmessage = "Sucessfully Append";
}
}
docDestination.PreserveWhitespace = true;
docDestination.Save(pathDestination);
Console.WriteLine(xmlMmessage);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
Console.ReadLine();
}
}
{
string _sourcePath = "";
string _configurationPath = "";
_sourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "UserInfo.xml");
_configurationPath = Path.Combine(Path.Combine(destFolder, "Configuration"), "UserInfo.xml");
if (!Directory.Exists(Path.Combine(destFolder, "Configuration")))
Directory.CreateDirectory(Path.Combine(destFolder, "Configuration"));
if (File.Exists(_configurationPath) == true)
{
updateUserInfoXML(_sourcePath, _configurationPath);
}
else //Create UserInfo.Xml file into Directory if not Exist in the Destination Path..
{
File.Copy(_sourcePath, _configurationPath, true);
}
}
static public void updateUserInfoXML(string pathSource, string pathDestination)
{
try
{
XmlDocument docSource = new XmlDocument();
XmlDocument docDestination = new XmlDocument();
string xmlMmessage = "";
docSource.Load(pathSource);
docDestination.Load(pathDestination);
XmlNodeList elemList = docSource.GetElementsByTagName("Asset");
//XmlNodeList elemListRoll = docSource.GetElementsByTagName("role");
//XmlNodeList elemListUser = docSource.GetElementsByTagName("User");
string attrAssetID;
XmlNodeList eleDestNodeList;
XmlNode eleDestinationNode = docDestination.DocumentElement;
foreach (XmlNode eleSourceNode in elemList)
{
attrAssetID = eleSourceNode.Attributes["assetid"].Value;
// attrRollID = eleSourceNode.Attributes["rollid"].Value;
//attrUserID = eleSourceNode.Attributes["Userid"].Value;
eleDestNodeList = docDestination.SelectNodes("/UserInfo/Asset[@assetid='" + attrAssetID.ToString() + "']");
if (eleDestNodeList.Count > 0)
{
eleDestinationNode = docDestination.SelectSingleNode("/UserInfo/Asset[@assetid='" + attrAssetID.ToString() + "']");
//docSource.AppendChild()
//---IF NODE EXISTS THEN REPLACE THE SOURCE NODE WITH TARGET NODE
XmlDocumentFragment fragment = docDestination.CreateDocumentFragment();
fragment.InnerXml = eleSourceNode.OuterXml;
eleDestinationNode.ParentNode.ReplaceChild(fragment, eleDestinationNode);
xmlMmessage = "Sucessfully replaced";
}
else
{
//---IF NODE IS NOT EXISTS THEN APPEND THE SOURCE NODE WITH TARGET NODE
XmlDocumentFragment fragment = docDestination.CreateDocumentFragment();
fragment.InnerXml = eleSourceNode.OuterXml;
eleDestinationNode.AppendChild(fragment);
xmlMmessage = "Sucessfully Append";
}
}
docDestination.PreserveWhitespace = true;
docDestination.Save(pathDestination);
Console.WriteLine(xmlMmessage);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
Console.ReadLine();
}
}
Create Xml File (using dataset)
StringBuilder _UserInfo = new StringBuilder();
dataset infoDS=new DataSet();
DataSet infoDS = PXE.Facade.PXEFacade.GetUserRoleOnAsset(bookId, nAssetId);
_UserInfo.Append("");
_UserInfo.Append("");
_UserInfo.Append("");
for (int i = 0; i < infoDS.Tables[0].Rows.Count; i++) { if (infoDS.Tables[0].Rows.Count > 0)
{
string _RoleId = infoDS.Tables[0].Rows[i]["roleid"].ToString();
string _UserId = infoDS.Tables[0].Rows[i]["userid"].ToString();
string _RoleName = infoDS.Tables[0].Rows[i]["roleName"].ToString();
string _Abbreviation = infoDS.Tables[0].Rows[i]["abbreviation"].ToString();
string _DisplayName = infoDS.Tables[0].Rows[i]["displayName"].ToString();
_UserInfo.Append("");
_UserInfo.Append(" ");
_UserInfo.Append(" ");
//_UserInfo.Append(" ");
if (File.Exists(tempFolder + "\\UserInfo.xml"))
{
File.SetAttributes(tempFolder + "\\UserInfo.xml", FileAttributes.Normal);
}
StreamWriter _sw1 = new StreamWriter(tempFolder + "\\UserInfo.xml");
_sw1.WriteLine(_UserInfo.ToString());
_sw1.Flush();
_sw1.Close();
_sw1.Dispose();
}
}
StreamWriter _sw = new StreamWriter(tempFolder + "\\UserInfo.xml");
_UserInfo.Append("");
_UserInfo.Append(" ");
_sw.WriteLine(_UserInfo.ToString());
_sw.Flush();
_sw.Close();
_sw.Dispose();
/**/
dataset infoDS=new DataSet();
DataSet infoDS = PXE.Facade.PXEFacade.GetUserRoleOnAsset(bookId, nAssetId);
_UserInfo.Append("");
_UserInfo.Append("
_UserInfo.Append("
for (int i = 0; i < infoDS.Tables[0].Rows.Count; i++) { if (infoDS.Tables[0].Rows.Count > 0)
{
string _RoleId = infoDS.Tables[0].Rows[i]["roleid"].ToString();
string _UserId = infoDS.Tables[0].Rows[i]["userid"].ToString();
string _RoleName = infoDS.Tables[0].Rows[i]["roleName"].ToString();
string _Abbreviation = infoDS.Tables[0].Rows[i]["abbreviation"].ToString();
string _DisplayName = infoDS.Tables[0].Rows[i]["displayName"].ToString();
_UserInfo.Append("
_UserInfo.Append("
_UserInfo.Append("
//_UserInfo.Append("
if (File.Exists(tempFolder + "\\UserInfo.xml"))
{
File.SetAttributes(tempFolder + "\\UserInfo.xml", FileAttributes.Normal);
}
StreamWriter _sw1 = new StreamWriter(tempFolder + "\\UserInfo.xml");
_sw1.WriteLine(_UserInfo.ToString());
_sw1.Flush();
_sw1.Close();
_sw1.Dispose();
}
}
StreamWriter _sw = new StreamWriter(tempFolder + "\\UserInfo.xml");
_UserInfo.Append("");
_UserInfo.Append("
_sw.WriteLine(_UserInfo.ToString());
_sw.Flush();
_sw.Close();
_sw.Dispose();
/**/
Labels:
Create Xml File (using dataset)
Sunday, November 14, 2010
Distinct Value from two array
string[] a1 = { "A", "B", "A", "C", "C" };
string[] a2 = { "A", "E", "C", "D", "C" };
// var unique = a1.Union(a2);
string[] a3 = new string[a1.Length + a2.Length];
a1.CopyTo(a3, 0);
a2.CopyTo(a3, a1.Length);
ArrayList arr = new ArrayList();
for (int k = 0; k < a3.Length; k++)
{
arr.Add(a3[k].ToString());
}
for (int i = 0; i < arr.Count - 1; i++)
{
for (int j = i + 1; j < arr.Count; j++)
{
if (arr[i].Equals(arr[j]))
{
arr.RemoveAt(j);
}
}
}
for (int i = 0; i < arr.Count; i++)
{
arr.Sort();
Console.WriteLine(arr[i]);
}
Console.ReadLine();
string[] a2 = { "A", "E", "C", "D", "C" };
// var unique = a1.Union(a2);
string[] a3 = new string[a1.Length + a2.Length];
a1.CopyTo(a3, 0);
a2.CopyTo(a3, a1.Length);
ArrayList arr = new ArrayList();
for (int k = 0; k < a3.Length; k++)
{
arr.Add(a3[k].ToString());
}
for (int i = 0; i < arr.Count - 1; i++)
{
for (int j = i + 1; j < arr.Count; j++)
{
if (arr[i].Equals(arr[j]))
{
arr.RemoveAt(j);
}
}
}
for (int i = 0; i < arr.Count; i++)
{
arr.Sort();
Console.WriteLine(arr[i]);
}
Console.ReadLine();
Labels:
Distinct Value from two array
Distinct Value from two array(Linq)
string[] a1 = { "A", "B", "A", "C", "C" };
string[] a2 = { "A", "E", "C", "D", "C" };
var unique = a1.Union(a2);
string[] a2 = { "A", "E", "C", "D", "C" };
var unique = a1.Union(a2);
Subscribe to:
Posts (Atom)