Click here to Skip to main content
15,921,716 members
Home / Discussions / C#
   

C#

 
AnswerRe: database Pin
PIEBALDconsult10-Dec-09 4:01
mvePIEBALDconsult10-Dec-09 4:01 
QuestionToo many namespaces in a class Pin
Abhinav S9-Dec-09 22:07
Abhinav S9-Dec-09 22:07 
AnswerRe: Too many namespaces in a class Pin
Migounette9-Dec-09 22:17
Migounette9-Dec-09 22:17 
AnswerRe: Too many namespaces in a class Pin
jdkulkarni9-Dec-09 22:20
jdkulkarni9-Dec-09 22:20 
GeneralRe: Too many namespaces in a class Pin
PIEBALDconsult10-Dec-09 3:56
mvePIEBALDconsult10-Dec-09 3:56 
AnswerRe: Too many namespaces in a class Pin
Richard MacCutchan9-Dec-09 23:40
mveRichard MacCutchan9-Dec-09 23:40 
AnswerRe: Too many namespaces in a class Pin
PIEBALDconsult10-Dec-09 4:03
mvePIEBALDconsult10-Dec-09 4:03 
QuestionC# -- Xml child node problem [modified] Pin
<<Tash18>>9-Dec-09 18:55
<<Tash18>>9-Dec-09 18:55 
Hi guys...
I have an issue with my xml file... actually im developing a console application which inserts the data from an Xml file
into my database... This happens with
certain verifications done within the console application, like
checking whether the application id given by the user matches with the application id present in the xml file and also whether that application
has certain permissions, like certain applications hav certain
previleges, sumthing like dat...
Accordingly the insertion of datas into the database takes place... the code is as follows:

class Class1
	{	
		public string app;
		public void perform()
		{
			OdbcConnection con= new OdbcConnection();
			ADIBCrypto.Encryption64 crpto = new ADIBCrypto.Encryption64();
			try
			{

				string connString = crpto.GetCnnStr(ConfigurationSettings.AppSettings["appname"],ConfigurationSettings.AppSettings["dsnSybase"]);
				con.ConnectionString = connString;
				con.Open();
				Console.WriteLine("Connection Opened Successfully");
				Console.WriteLine("Enter the application");
				app=Console.ReadLine();
				XmlDataDocument doc = new XmlDataDocument();
				doc.Load(ConfigurationSettings.AppSettings["app"]);
				XmlNodeList nodes = doc.GetElementsByTagName("Row");
				foreach(XmlNode node in nodes)
				{ 
					if(node.HasChildNodes && node.ChildNodes.Count > 0)
					{
						string a_ID = node.ChildNodes[0].InnerText;
						string a_ApplicationDescription = node.ChildNodes[1].InnerText;
						string a_Category = node.ChildNodes[2].InnerText;
						string a_Business_Owner = node.ChildNodes[3].InnerText;
						string a_CreatedID = node.ChildNodes[4].InnerText;
						string a_CreatedTimeStamp = node.ChildNodes[5].InnerText;
						string a_Status = node.ChildNodes[6].InnerText;
						if(a_ID==app)
						{
							//OdbcCommand cmd = new OdbcCommand("insert into EACS_Application values('"+a_ID+"','"+a_ApplicationDescription+"','"+a_Category+"','"+a_Business_Owner+"','"+a_CreatedID+"',getDate(),'"+a_Status+"','','','','','','','')",con);
							//cmd.ExecuteNonQuery();
							Console.WriteLine("App Inserted");
						}
					}
				}
							XmlDataDocument doc1 = new XmlDataDocument();
							doc1.Load(ConfigurationSettings.AppSettings["fun"]);
							XmlNodeList nodes1 = doc1.GetElementsByTagName("Row");
							foreach(XmlNode node1 in nodes1)
							{
								if(node1.HasChildNodes && node1.ChildNodes.Count > 0)
								{
									string f_ID = node1.ChildNodes[0].InnerText;
									string f_FunctionDescription = node1.ChildNodes[1].InnerText;
									string f_AppId = node1.ChildNodes[2].InnerText;
									string f_FileName = node1.ChildNodes[3].InnerText;
									if(f_AppId==app)
									{
										Console.WriteLine("fun--{0}",f_FileName);
										XmlDataDocument doc2 = new XmlDataDocument();
										doc2.Load(ConfigurationSettings.AppSettings["funfile"]+"\\"+f_FileName+".xml");
										XmlNodeList nodes2 = doc2.GetElementsByTagName("Function");
										foreach(XmlNode node2 in nodes2)
										{
											if(node2.HasChildNodes && node2.ChildNodes.Count > 0)
											{
												string ff_Id = node2.ChildNodes[0].InnerText;
												string ff_FunctionDescription = node2.ChildNodes[1].InnerText;
												string ff_Url = node2.ChildNodes[2].InnerText;
												string ff_AppId = node2.ChildNodes[3].InnerText;
												string ff_Type = node2.ChildNodes[4].InnerText;
												string ff_MenuCommand = node2.ChildNodes[5].InnerText;
												string ff_Status = node2.ChildNodes[6].InnerText;
												Console.WriteLine("funfile--{0}",ff_Id);
												//OdbcCommand cmd1 = new OdbcCommand("insert into EACS_Function values('"+ff_Id+"','"+ff_FunctionDescription+"','"+ff_Url+"','"+ff_AppId+"','"+ff_Type+"','"+ff_MenuCommand+"','"+ff_Status+"','','','')",con);
												//cmd1.ExecuteNonQuery();
											}
											
										}
									}
								}
							}
							Console.WriteLine("Function Inserted");
							XmlDataDocument doc3 = new XmlDataDocument();
							doc3.Load(ConfigurationSettings.AppSettings["fungrp"]);
							XmlNodeList nodes3 = doc3.GetElementsByTagName("Row");
							foreach(XmlNode node3 in nodes3)
							{
								if(node3.HasChildNodes && node3.ChildNodes.Count > 0)
								{
									string fg_GroupId = node3.ChildNodes[0].InnerText;
									string fg_AppId = node3.ChildNodes[1].InnerText;
									string fg_FuncId = node3.ChildNodes[2].InnerText;
									string fg_FileName = node3.ChildNodes[3].InnerText;
									if(fg_AppId==app)
									{
										XmlDataDocument doc4 = new XmlDataDocument();
										doc4.Load(ConfigurationSettings.AppSettings["fungrpfile"]+"\\"+fg_FileName+".xml");
										XmlNodeList nodes4 = doc4.GetElementsByTagName("FunctionGroup");
										foreach(XmlNode node4 in nodes4)
										{
											if(node4.HasChildNodes && node4.ChildNodes.Count > 0)
											{
												string fgf_GroupId = node4.ChildNodes[0].InnerText;
												string fgf_AppId = node4.ChildNodes[1].InnerText;
												string fgf_FuncId = node4.ChildNodes[2].InnerText;
												string fgf_Status = node4.ChildNodes[3].InnerText;
												Console.WriteLine("fungrp--{0}",fgf_FuncId);
												//OdbcCommand cmd2 = new OdbcCommand("insert into EACS_FunctionGroup values('"+fgf_GroupId+"','"+fgf_AppId+"','"+fgf_FuncId+"','"+fgf_Status+"','')",con);
												//cmd2.ExecuteNonQuery();
												XmlDataDocument doc5 = new XmlDataDocument();
												doc5.Load(ConfigurationSettings.AppSettings["grp"]);
												XmlNodeList nodes5 = doc5.GetElementsByTagName("Row");
												foreach(XmlNode node5 in nodes5)
												{
													if(node5.HasChildNodes && node5.ChildNodes.Count > 0)
													{
														string g_Id = node5.ChildNodes[0].InnerText;
														string g_Description = node5.ChildNodes[1].InnerText;
														string g_FileName = node5.ChildNodes[2].InnerText;
														if(fgf_GroupId==g_Id)
														{
															XmlDataDocument doc6 = new XmlDataDocument();
															doc6.Load(ConfigurationSettings.AppSettings["grpfile"]+"\\"+g_FileName+".xml");
															XmlNodeList nodes6 = doc6.GetElementsByTagName("Group");
															foreach(XmlNode node6 in nodes6)
															{
																if(node6.HasChildNodes && node6.ChildNodes.Count > 0)
																{
																	string gf_Id = node6.ChildNodes[0].InnerText;
																	string gf_Description = node6.ChildNodes[1].InnerText;
																	string gf_Type = node6.ChildNodes[2].InnerText;
																	string gf_Level = node6.ChildNodes[3].InnerText;
																	int gf_DailyLimit = Convert.ToInt32(node6.ChildNodes[4].InnerText);
																	string gf_Status = node6.ChildNodes[5].InnerText;
																	Console.WriteLine("grp--{0}",gf_Id);
																	//OdbcCommand cmd3 = new OdbcCommand("insert into EACS_Group values('"+gf_Id+"','"+gf_Description+"','"+gf_Type+"','"+gf_Level+"',"+gf_DailyLimit+",'"+gf_Status+"','','','','')",con);
																	//cmd3.ExecuteNonQuery();
																}
															}
														}
																						}
												}
											}
										}
									}
								}
							}
				con.Close();
				Console.WriteLine("Connection Closed");
				Console.ReadLine();
			}
		
			catch(OdbcException)
			{
				Console.WriteLine("Record already exists");
				Console.ReadLine();
			}
		}


The problem is that on loading the "doc3" the tags in the xml file are not in the same order.. The Xml file is as follows:

<Row>
    <AppId>CAPRC</AppId>
    <GroupId>CAPRC02</GroupId>
    <FuncId>cap63</FuncId>
    <FileName>FG_53</FileName>
  </Row>
  <Row>
    <GroupId>ICCBranch</GroupId>
    <AppId>ICC</AppId>
    <FuncId>00001</FuncId>
    <FileName>FG_54</FileName>
  </Row>
<Row>
    <GroupId>ICCBranch</GroupId>
    <AppId>ICC</AppId>
    <FuncId>00002</FuncId>
    <FileName>FG_55</FileName>
  </Row>
  <Row>
    <AppId>ICC</AppId>
    <GroupId>ICCCardCen</GroupId>
    <FuncId>00003</FuncId>
    <FileName>FG_56</FileName>
  </Row>


so u can see that the AppID and the GroupId tags are not in the right order.. in certain rows the tag-appid is in childnode[0]
and in certain rows the tag
is in Childnode[1]... so my check in the application is not
performed properly.. instead of childnode index number can i make it check with the name of the tag...
please guide i am 95% done with my application and at the final stage i found out this bug WTF | :WTF: Frown | :( ... please guide me with
any better ideas...
Thanxx in advance...
Regards,
Tash

modified on Thursday, December 10, 2009 3:44 AM

AnswerRe: C# -- Xml child node problem Pin
Covean9-Dec-09 22:47
Covean9-Dec-09 22:47 
QuestionI'm Having Way Too Much Fun (but I have another question...) Pin
Roger Wright9-Dec-09 18:39
professionalRoger Wright9-Dec-09 18:39 
AnswerRe: I'm Having Way Too Much Fun (but I have another question...) Pin
dan!sh 9-Dec-09 20:58
professional dan!sh 9-Dec-09 20:58 
GeneralRe: I'm Having Way Too Much Fun (but I have another question...) Pin
Roger Wright10-Dec-09 18:42
professionalRoger Wright10-Dec-09 18:42 
AnswerRe: I'm Having Way Too Much Fun (but I have another question...) Pin
PIEBALDconsult10-Dec-09 3:50
mvePIEBALDconsult10-Dec-09 3:50 
QuestionDataGridViewColumn can be accessed by multiple threads [modified] Pin
jdkulkarni9-Dec-09 18:33
jdkulkarni9-Dec-09 18:33 
Questionreg creation of multi file assembly Pin
sandhiyaus9-Dec-09 17:50
sandhiyaus9-Dec-09 17:50 
AnswerRe: reg creation of multi file assembly Pin
PIEBALDconsult9-Dec-09 18:10
mvePIEBALDconsult9-Dec-09 18:10 
QuestionTrying to use HashSet<t></t> Pin
BobInNJ9-Dec-09 13:38
BobInNJ9-Dec-09 13:38 
AnswerRe: Trying to use HashSet Pin
N a v a n e e t h9-Dec-09 14:53
N a v a n e e t h9-Dec-09 14:53 
QuestionDelete a word everytime the program see it. Pin
ahlm9-Dec-09 10:54
ahlm9-Dec-09 10:54 
AnswerRe: Delete a word everytime the program see it. Pin
Migounette9-Dec-09 11:56
Migounette9-Dec-09 11:56 
AnswerRe: Delete a word everytime the program see it. Pin
Abhinav S9-Dec-09 17:13
Abhinav S9-Dec-09 17:13 
GeneralRe: Delete a word everytime the program see it. Pin
ahlm9-Dec-09 18:31
ahlm9-Dec-09 18:31 
QuestionSqlCeResultSet Problem [modified] Pin
Stanciu Vlad9-Dec-09 6:25
Stanciu Vlad9-Dec-09 6:25 
AnswerRe: SqlCeResultSet Problem Pin
Migounette9-Dec-09 12:19
Migounette9-Dec-09 12:19 
QuestionRe: SqlCeResultSet Problem Pin
Stanciu Vlad9-Dec-09 20:09
Stanciu Vlad9-Dec-09 20:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.