|
Hi
I have did a program such that , i will have two text box name and age in my form..and a button named save. so that when the values entered r in the text box..a xml file is created with those data..
.
Now I can able to create one set of values…. Now what I need is that when again some other value is entered in the textbox. It should also be written in the xml file..but without deleting the other. I mean it should append on the other..
For example: first I entered first as john and 22 for name and age ..it will added in the xml file..now again if I enter charu and 23 as name and age..
Now xml should have john and 22 as well as charu and 23…
And also one more thing is that if I again enter John. It should give a message that it has already been entered. No values should be repeated again. Please help me to do this…..
The coding which I did is as follows.
In side the button click
//save Button
private void button1_Click(object sender, System.EventArgs e)
{
DataSet dataSet = new DataSet();
//read the schema
dataSet.ReadXmlSchema("..\\..\\PlaygroMenu.xsd");
//create a new row
DataRow oValues;
oValues = dataSet.Tables[0].NewRow();
//enter the values
oValues[0] = txtName.Text;
oValues[1] = Convert.ToInt32(txtAage.Text);
//check for duplication
bool hasalready = false;
foreach(DataRow row in dataSet.Tables[0].Rows)
{
if(row.ItemArray[0].ToString().Equals(txtID.Text))
{
hasalready = true;
}
}
//
if(!hasalready)
{
//add the row to the dataset
dataSet.Tables[0].Rows.Add(oValues);
//write the data to a xml file
dataSet.WriteXml("..\\..\\resultdata.xml", XmlWriteMode.WriteSchema);
MessageBox.Show("Saved");
}
else
{
MessageBox.Show("Already Exists");
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
DataSet dataSet = new DataSet();
//read the schema
dataSet.ReadXmlSchema("..\\..\\Menu.xsd");
System.IO.FileInfo file = new System.IO.FileInfo("..\\..\\mydata.xml");
//check whethere there is result xml file...
if (file.Exists)
{
dataSet.ReadXml("..\\..\\resultdata.xml");
}
}
Please help me to do this..
Dhol
|
|
|
|
|
Hi All,
Wish all of you a very happy new year.....
I want to submit a form based on a condition as I am doing with ASP. I have a user login form and i m checking the username and password with the database (SQLServer 2000).
I want to do it in C# using ASP.net
User will fill the form,
username and password will be checked from the database.
If no record found, form will be submitted on login.aspx, and if record found, it will be submitted on account.aspx.
I m doing this by ASP code, but I want to use this in C# (Code behind) so that no body can see my code as it will be go will dll...
I also don't want to use Response.Redirect()...
function Validate()
{
document.login.submit();
}
Validate();
Is there any way ????
Regards,
Suman Singh
-- modified at 7:46 Thursday 5th January, 2006
|
|
|
|
|
Put runat="server" in the fields and use id to identify them:
<input type="hidden" id="CustNum" runat="server"/><br />
<input type=hidden id="mode" ruant="server"/>
Now you can declare them in code-behind:
protected HtmlInputHidden CustNum, mode;
And set the values:
CustNum.Value = "42";<br />
mode.Value = "Paranoid";
---
b { font-weight: normal; }
-- modified at 8:15 Thursday 5th January, 2006
|
|
|
|
|
and what will be the code to submit the form....
|
|
|
|
|
The same as you have now.
---
b { font-weight: normal; }
|
|
|
|
|
Does anyone has the experience on the vector graphics programming? Now,I wanna find out how to write codes to edit the vector graphics,such as the wmf format graphics file. Anyone could give me some ideas about it or codes on it? I really appreciate it for your help!
Richard
|
|
|
|
|
Hi!
Marc Clifton has published a nice article here on CP: Vector based clock[^]
Definitvely worth a read.
Regards,
mav
|
|
|
|
|
Hello, I wonder where this often appearing error comes from. I'd guess nearly every programmer knows the "...is being used by another process" problem.
My situation:
In my application I need to perform a couple of tasks on a single file like:
- writing some bytes into it
- copy it (I cannot use File.Move() at his point)
- and shortly after that: rename the copy with File.Move()
When executing next command after File.Copy() that also accesses the file (no matter if that is Move(), another Copy() command, or whatever) I get the classic exception with the errormessage "Cannot access file XYZ because it is being used by another process."
If I simply catch the exception - and do nothing within the catch block - the file operations all work SUCCESSFULLY.
So my question is, what is going on there?
Is it a possibly explanation that the execution of the application already continues although File.Copy() has not finished, and so the next file operation command accesses too early?
Is there a more elegant way to solve this other than an empty try...catch block?
I am sure there is... but what?
I'm curious about your opinions.
|
|
|
|
|
Are you closing the file handle after writing bytes to the file? You'll get the exception you mentioned if you don't.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi!
Are you sure the File.Copy() is the reason? If you're "writing some bytes into it" I think it's more likely that you didn't close your File or FileStream properly.
Some code would definitively help.
Regards,
mav
|
|
|
|
|
Yes the stream is closed, I just checked that again.
I'll post some code tomorrow when I get back to work.
|
|
|
|
|
Pls tell me how to put data from an IList to a Dataset.
Regards.
|
|
|
|
|
you are using
.NET 1.1 or 2.0?
regards
GV Ramana
|
|
|
|
|
I'm using .net 1.1. Pls tell me how to put data from an IList to a Dataset, in both .net 1.1 and .net 2.0. Thanks.
-- modified at 6:49 Thursday 5th January, 2006
|
|
|
|
|
Hi undead,
Your question is not proper.
However Where IList Interface is Implemented weather explicitly u r implementing? if yes, If Add method is implemented in your class, take for each loop and with IList.IndexOf(i)store in a DataSet.
Still you not get my answer, give detail question & requirement.
bye
regards
GV Ramana
|
|
|
|
|
Thanks with your help. I'm sorry that I didn't give u detail question & requirement.
I used Oject.Net to get data from a database to an IList (function PersistenceManager.getAllObjectsFromDb(typeof(Student));)
public class Student
{
int m_StudentId;
string m_Name;
string m_Email;
....
}
When I run, it will return an IList containing an array of Student object. After that I bind this IList to a datagrid, it's OK, but I don't know how to sort data in this IList (ex : m_Name DESC) so that I want to change it to a datatable (or dataset) to use the dataview to sort data.
How to do that???
|
|
|
|
|
Hi there!
After build my project it runs on my computer without problems. After installing that on my laptop it doesnt work.
The application uses 2 dlls coded in c++. when the application starts, it cant access the dlls.
http://msdn2.microsoft.com/en-us/library/ms235317.aspx --> desribes a workaround
I have to set a PATH environment variable in System-Advanced-Environment Variable under Windows XP.
But I have no idea how to make it with an *.bat file.
Is it possible to place the path variable in the registry?
|
|
|
|
|
In your installation project, open the Registry view and add your custom values as children to the "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" key.
NOTE: As always, you assume risk when changing the registry. Doing so can cause your system to become unstable or unusable. Please, do so at you own risk.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I have a problem,
i build an aspx page a normal webform, on this i use a control from somewhere deep in the internet, it looks like a textbox, but has a small calendar attached, doesnt matter, works fine. The Problem is, that textbox has no 'TextChanged' Event, but i really need this one.
So my question is, could anybody help me, how to add this event to this custom TextBox, means how to add an event which is fired when the text in this box is changed!
Or in general how to create new events for existing controls/classes or whatever, damn .NET!
Hope someone is genius on that and can help me out soon,
looking forward not to kill myself
regards
Balu
|
|
|
|
|
|
Thanks for the fast reply,
i cant do this in Javascript cause i have to interact with another vb script editor and i cant use scripts on the html side, i need to pass my data from the code behind page, i have to use the event mentioned in the first post, to make an Sql call and then transfering recieved data to a vb script on whether the html side or in this special vb script editor!
I will see if the articel you posted could help me out!
If there are any other articles, how-to´s what ever on this topic, please post it!
Thanks again,
regards
Balu
|
|
|
|
|
how to create/extend the some of the standard controls like radio buttons / check boxes to make them more touch screen friendly.
It would be helpful if you can provide the options as early as possible
Thanks
Madhu Srinivasan
|
|
|
|
|
Do you just want larger targets for the touch screen? If so, just change their Height and Width properties to affect that. Ensure that the larger controls do not overlap.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi
Is there any tool in VS 2005 to do unit testing, creating test report.
Thanks and Regards
Srini
srini
|
|
|
|
|
I'm running beta 2, and there is a testing framework(?) built into it. Check out the (would you have guessed it?) Test menu.
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|