|
Hi to all,
I am writting a C# Windows Application in which it uses XML to store & retrieve Student Data (like Name, Addres, DOB, Educational Details, Economical Conditions, etc).
To store & retrieve data from XML, I am using XmlSerializer class.
But some student data are in form of paragraph (like Educational Details, Economical Conditions, ..). How to store & retrieve that data using same XmlSerializer class?
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
It's just XML. You can put carriage returns inside the data.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Thanks for reply.
Where & How to put carriage return?
If I am getting a value for an attribute as "Test Line1\nTest Line 2\nTest Line3" from XML; then
do u mean to convert it to "Test Line1\r\nTest Line 2\r\nTest Line3".
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
Following is working properly, without taking care of carriage return.
Here I am using XmlTextReader & XmlTextWriter instead of FileStream.
//XML to .NET Object (Reading XML)
using (XmlTextReader xtr = new XmlTextReader(new StreamReader(sXmlPath)))
{
XmlSerializer xserObject = new XmlSerializer(typeof(Child));
objChild = (Child)xserObject.Deserialize(xtr);
//objChild = xserObject.Deserialize(xtr) as Child;
xtr.Close();
}
//.NET Object to XML (Writting XML)
using (XmlTextWriter xtw = new XmlTextWriter(new StreamWriter(sXmlPath)))
{
XmlSerializer xserObject = new XmlSerializer(typeof(Child));
xserObject.Serialize(xtw, objChild);
xtw.Flush();
xtw.Close();
}
Once again thanks for your support.
|
|
|
|
|
Hi everybody!
I have a problem in the search for datagridview. I can not do that. You can help me understand the process, the sample code or help me with. Thank you!
modified on Sunday, July 5, 2009 12:20 AM
|
|
|
|
|
ducanhthanhhoa wrote: I have a problem in the search for datagridview
Datagridview does not provide any fuctionality to search on its own.
ducanhthanhhoa wrote: You can help me understand the process, the sample code or help me with. Thank you!
What have you tried so far?
Infact, its better to search the DataSource which is bound to the datagridview.
Do you know how to filter results from a datatable? You can use dataview [^]for that purpose.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Thank you I can filter data from the database but can not search on the datagridview. Help me!
modified on Friday, August 7, 2009 2:06 AM
|
|
|
|
|
OK - I have a listview (details) that contains multiple rows with each row having multiple columns of data.
For each selected row, I want to create a text file record that contains the data from the multiple columns from the selected listview row.
Thanks!
|
|
|
|
|
Robert Bone wrote: For each selected row, I want to create a text file record that contains the data from the multiple columns from the selected listview row.
What did you try till now?
Are you facing problem somewhere?
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Well, I haven't tried anything, as I have no clue. I looked at a bunch of examples of writing to text files, but none of them did what I am trying to do. I have certainly created text files from data before, but it has always just been single-column data written to a text file record.
So, if my listview rows look like:
Frankfurters REG_SZ C:\Windows\Blah\Blah
Hamburgers REG_SZ D:\SomewhereOverTheRainbow
then I want to take the data from the multiple columns on each row and create a text file record that looks like what is displayed above (for wach row) - I later want to be able to properly retrieve and separate the text file records into multiple columns for downstream manipulation.
|
|
|
|
|
Rather than just a plain text file, I would suggest either XML or CSV for this.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I'm afraid a bit of punctuation marks will not cure a writer's block.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks for the quick reply. I am a transplanted mainframer. Can you give me an example to write such a file? Either one is fine by me, as long as it is a commonly accessible format on remote machines.
|
|
|
|
|
Hello,
I would save my repports on txt file i try for :
<br />
StreamWriter monStreamWriter = new StreamWriter(path + ":\\Batch_BDD_PROD\\nb\\TXT.txt"); <br />
<br />
try<br />
{<br />
monStreamWriter.WriteLine("Ma toute2 première ligne ..."); <br />
}<br />
finally<br />
{<br />
monStreamWriter.Close();<br />
}<br />
<br />
So the line witch write deleted on every execution of my program, how i can add a lines? thank you verry mutch.
|
|
|
|
|
abbd wrote: So the line witch write deleted on every execution of my program, how i can add a lines?
You are opening a stream and writing from the start. You need to open the stream and write at the end.
You might find this article in MSDN on How to Open and Append to a ... file[^] useful.
|
|
|
|
|
You will need to get the FileStream yourself and make sure the stream is at the end of the file. You can then pass that to the StreamWriter, and it will add text on, rather than overwriting it.
Pretty simple:
FileStream fs = new FileStream(path + ":\\Batch_BDD_PROD\\nb\\TXT.txt", FileMode.Append);
StreamWriter monStreamWriter = new StreamWriter(fs);
try
{
monStreamWriter.WriteLine("Ma toute2 première ligne ...");
}
finally
{
monStreamWriter.Close();
}
EDIT: Beaten again! Must type faster!
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
I have problem in C# when I want to drop text on my textbox. If I drag tet form notepad it work ok, but if that text is html link I end up with link to the page, not link caption, withc I want.
I use thise
string tmp = (string)e.Data.GetData(DataFormats.Text);
How can I know what type of object is over control, if it is link from browser what should I do. I saw html type and I could parse it but my problem is how to know that object is link, and not a plain text.
Did I make myself clear?
|
|
|
|
|
Hi,
not sure I understand you correctly. You are dragging some text, which might be a URL? and if so, you want the content of that page rather than its URL?
If that is what you want, then you have to write code to that effect. Check the text starts with "http" and when it does, use WebRequest/WebResponse to get the content. If it fails, drop the URL; if it succeeds, drop the content (which could well be a lot of HTML mumbo jumbo, or an image, or just almost anything).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Sory on bad formating. That is exactly what I want. So there is no automatical way to do that, i must to parse. There is html format witch i can parse, beter then using browser, but i was hope that there is easyer way to do this.
Thenks alot.
|
|
|
|
|
I need code in C# to split a string in blocks of 16.
plz suggest me a code.....
|
|
|
|
|
|
Hello Guys :
i really in a deep trouble an tried many way to solve it but couldn't find a solution.
1st am getting my data from xml file....when my application load the dataset reads the data from the xml file.
in the xml file i have two tables : (Product) and (ProductInfo)
tables product consist of (ID"Pk",Type).
and productInfo consist of (ID,Description,Brand,PructType"Fk").
there is a relation between those two tables.
now the problem is i want to show the table (ProductInfo) in the Daragrid but get the type from the Product Table.in other words i want to show coulmns from multiple tables in 1 Datagrid and in 1 view through the relation.i mean i want the Datagrid to view (ID,Description,Brand,Type)
the first 3 from ProductInfoTable an the last one from the Product table.
to be exact i want to do something like the "JOIN" function in SQL Server.
i did that before but i was using SQL Server Database and made View and selected teh coulmns i needed from different tables and the view were like another new table but with the two tables data....and i selected the datasource infor my datagrid that View and with table styles i hid what i wanted to hid.but even now tablestyles not working.....any help or idea will be apprciated.
modified on Saturday, July 4, 2009 8:21 AM
|
|
|
|
|
I want to determine HTTP header code of a URL by C# code. How could I get that?
I use the following code :
<br />
public Dictionary<string, string> GetHTTPResponseHeaders(string Url)<br />
{<br />
Dictionary<string, string> HeaderList = new Dictionary<string, string>();<br />
<br />
WebRequest WebRequestObject = HttpWebRequest.Create(Url);<br />
WebResponse ResponseObject = WebRequestObject.GetResponse();<br />
<br />
foreach (string HeaderKey in ResponseObject.Headers)<br />
{<br />
HeaderList.Add(HeaderKey, ResponseObject.Headers[HeaderKey]);<br />
textBox1.Text += HeaderKey + ": " + ResponseObject.Headers[HeaderKey]+" " ;<br />
}<br />
ResponseObject.Close();<br />
<br />
return HeaderList;<br />
}<br />
but It does not contain of HTTP header Code!
|
|
|
|
|
Nafiseh Salmani wrote: WebResponse ResponseObject = WebRequestObject.GetResponse();
This should be cast to an HttpWebResponse if the Url you are passing uses HTTP or HTPS as the protocol.
HttpWebResponse responseObject = (HttpWebResponse)WebRequestObject.GetResponse();
You will then find a StatusCode property which contains the detail you want.
|
|
|
|