Using XmlDataDocument with DataSet  
Author Message
ADNAN_1





PostPosted: XML and the .NET Framework, Using XmlDataDocument with DataSet Top

Hi people.

I'm new to C# and .NET and I'm trying to write an application to store passwd.

In the program I used XmlDataDocment to create passwd tables and everthing's fine. But when i try to save XmlDataDocument, I have limited options. I can't write the content to a file, because I want them to be encryted in file. If I had used DataSet , I could pass the content to memorystream and save it by encrypting.

I could not see any possible opportunity to do this with XmlDataDocument. Or is there a way

Or the best solution for this (if possible), Can I pass the Xml data from XmlDataDocument to DataSet without using files

Thanks in Advance..



.NET Development36  
 
 
Martin Honnen





PostPosted: XML and the .NET Framework, Using XmlDataDocument with DataSet Top

Or the best solution for this (if possible), Can I pass the Xml data from XmlDataDocument to DataSet without using files

An XmlDataDocument instance has a property DataSet that gives you the data set matching the XML. And XmlDataDocument has a constructor allowing you to create an XmlDataDocument from a data set.



 
 
ADNAN_1





PostPosted: XML and the .NET Framework, Using XmlDataDocument with DataSet Top

Thanks for the reply.

I tried to use the XmlDataDocument.DataSet property but i could not sync them. So I decided only use DataSet to represent my Tables.

However I now have another problem.

I created DataTable and a few Columns. When the first instance of the program runs, there is no problem of fetching or inserting data by DataRow objects, but when i save the DataSet to a file and restart the program, after the program reads the Dataset, fetching data process gives errors in converting data types. I tried to use casting but it gives errors casting data with same types..

For Example, I first used:

string tmp_username = (string)row["Username"];

string tmp_passwd = (string)row["Passwd"];

After error I used this one:

string tmp_username = row["Username"].ToString();

string tmp_passwd = row["Passwd"].ToString();

Both are resulted in error and in the DataTables "Username" and "Passwd" columns are defined as string. Is there a way to get rid of this problem


 
 
Martin Honnen





PostPosted: XML and the .NET Framework, Using XmlDataDocument with DataSet Top

Do you first save and later load a schema for the data set That way there should not be a problem.

 
 
ADNAN_1





PostPosted: XML and the .NET Framework, Using XmlDataDocument with DataSet Top

Hi!

I haven't used the schema before, cause I had only a simple table with a few columns and thought DataSet could get the schema itself.

I saved the schema with xml data of DataSet. After restarting the program, loading both schema and Xml of DataSet helped to get rid of the errors..

Thanks for the reply.

One last question. It's more about security. As I'm keeping the passwd profiles in DataSet, I encrypted the xml data representing the table, but I didn't encrypt the schema. As it only keeps the format of the table, i decided to keep it unencrypted. Is it safe

And if I encrypt (with symetric algorithm) it, i will most probably use the same key that I used for XML table..Can this be a handicap

Thanks in advance..