|
hello all,
I want to deserialize an xml file.This xml has one attribute as xsi:type="value". When i do deserialization xml without this xsi:type thn it works, but when I include this an exception occures.
Please help is there any idea behind it.
Thanks in advance...
|
|
|
|
|
Can you elaborate more by posting here your
xml file or with some sample data, to understand
the scenario?
I think your xml file is not pure, contain
some invalid data that's why it is failing
during serialization.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
<PARAMS>
<PARAM xsi:type="VALUE" SEMANTIC="DATA">
<SHORTNAME>PARAM_0</SHORT-NAME>
<DOP-REF IDREF="DOP_MDiffAccelMap02RowAxis"/>
</PARAM>
</PARAMS>
this is the xml file generated..
|
|
|
|
|
Ok, I have dig our more and I found this[^] link.
According to this this is (content xsi is generated serialized xml.
So can you give me the exception or error you are receiving during deserialization?
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
It is not giving a specific exception.When I run code of deserialization it halts and give a general exception like deserialization fail and indiacte at the line whcih contains xsi:type.
|
|
|
|
|
Refer this[^] link, it will resolve your problem.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
I have same problem as in the linke given by you. Bt I am not getting how it will solve...
plz help..
|
|
|
|
|
Just go through whole article, the resolution is below related questions links.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
sorry to disturb u again....
I am not able to find related questions links.
|
|
|
|
|
This code might get you on the right track:
XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
namespaces.Add("", "");
namespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema");
XmlSerializer serializer = new XmlSerializer(typeof(MyObject));
serializer.Serialize(File.Create("all.xml"), customers, namespaces);
|
|
|
|
|
hello
I have serialized that objects into xml. But problem is in desrialization due to "xsi:type=VALUE".
I have also serialized using code given by U bt still deserialization is problem.
Plz do needful...
Thanks in adv.
|
|
|
|
|
Did you deserialize with the code given? Also, my code is a starting point for something to try. Attempt variations of namespaces, etc.
|
|
|
|
|
I think given code is for serialization not for deserialization because u used serialize() method instead deserialize() and also create an *.xml file. If I am wrong then plz guide me.
Thnx in adv...
|
|
|
|
|
Hello all
Im comparing two data tables(with same structure)and i want to insert the row difference into the first table
eg
table 1 table 2
ColA ColB ColC ColA ColB ColC
A B C A B C
C D A A A A <---new row
D A C C D A
D A C
as you can see , 2nd row in table 2 is new and I want to insert the difference into table1
|
|
|
|
|
There isn't any automated way to achieve the same.
You need to do it manually.
Just loop datatable for the number of rows for the
datatable has greater rows. i.e.
DataTable1 contains 5 rows
DataTable2 contains 6 rows
then write
for(i=0;i<<DataTable2.Rows.Count;i++)
{
for(j=0;j<<DataTable1.Rows.Count;j++)
{
for(t=0;t<<DataTable1.Columns.Count;t++)
{
}
}
}
Then manually compare each row and each column. You need to take two flags.
First flag set when the column of DataTable1 is not matched with DataTable2
for particular row.
Second flag set when there is new row in DataTable2 not matched with any row
of DataTable1.
And accordingly you can take actions.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
The first thing to try is an INSERT...SELECT...WHERE statement, but that won't work in all cases.
If I have to resort to programming, then depending on the situation (number of rows and columns etc.), I might just throw all the rows in table 2 at table 1 and see what sticks.
0) Ensure that table 1 has a unique index that covers everything that needs to be covered.
1) Set up a parameterized INSERT command for table 1 (this requires a second Connection)
2) Open a DataReader against table 2.
3) Iterate the DataReader
3.1) Set the parameters
3.2) In a try/catch, Execute the INSERT, and ignore (or log) duplicate exceptions
This allows the database to check whether or not the row exists so you don't wind up checking it twice. The big sticking point is the index -- how much data will need to be in the index?
You may also want a Transaction.
Edit: Oh, wait, you meant DataTables? Why would you need to do that?
|
|
|
|
|
Hello,
I am using C# desktop applications.Here I am saving some files into the database and i wanted to read those files back and depending upon my extension it should open in corresponding files.For eg,.doc file in msword,pdf in adobe like that.
I am facing a problem in opening the file .I have binary data in a byte array.How will i do it.Please help
seeism
|
|
|
|
|
Most apps need physical files for their documents, so create a document file (could be in a temp folder), then pass its path to Process.Start() to launch the associated application to open it.
Note: the app may remain open after you're done.
|
|
|
|
|
hey
thanks for that
this is what i actually want.Now i able to open a word document if my file that stored was doc but it is coming as junk value.What could be the reason ???
seeism
|
|
|
|
|
Hi,
I am able to read only the first char of bytes from db.What could be the reason.Now in txt file ,it is opening and prints the first char but for doc,it is coming junk data
seeism
|
|
|
|
|
|
Hi,
I am not getting any error.I just want to open a file in the same application and now my problem is solved using this
String new_FileName = Path.ChangeExtension(Path.GetTempFileName(), "txt");
File.WriteAllBytes(new_FileName, result);
System.Diagnostics.Process.Start(new_FileName);
But now i getting junk values for doc data.
|
|
|
|
|
why would you change the extension? if it is a Word document, NotePad will not be able to open it properly.
The normal thing to do is to use two database fields: one for the filename (including extension!), one for the binary data (the actual file content).
|
|
|
|
|
Soory i pasted the code for txt here.I put it as doc while opening the doc file.For doc file it is coming junk data.For txt first char is printing
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable());
dt.Load(dr);
result = (Byte[])dt.Rows[0]["File_Doc"];
when i check this result array it is contiaing the first byte value and all others r zero
Why so
|
|
|
|
|
use your database management tool to check the content of the field, and determine whether the problem is in storing or in retrieving the data.
BTW: you don't need a DataReader, a simple ExecuteScalar could suffice, see here e.g.: Save An Image Into SQL Server 2000 Database[^]
|
|
|
|