Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
AnswerRe: How do I copy a file and display progress? Pin
Guinness4Strength27-May-04 11:42
Guinness4Strength27-May-04 11:42 
AnswerRe: How do I copy a file and display progress? Pin
Dave Kreskowiak27-May-04 11:43
mveDave Kreskowiak27-May-04 11:43 
GeneralRe: How do I copy a file and display progress? Pin
Jonathan Slenders28-May-04 0:28
Jonathan Slenders28-May-04 0:28 
GeneralRe: wsdl converter Pin
mjmcinto27-May-04 10:12
mjmcinto27-May-04 10:12 
GeneralDataTable.Select and Expressions Pin
rog103927-May-04 9:18
rog103927-May-04 9:18 
GeneralRe: DataTable.Select and Expressions Pin
Heath Stewart27-May-04 10:03
protectorHeath Stewart27-May-04 10:03 
GeneralRe: DataTable.Select and Expressions Pin
rog103927-May-04 10:26
rog103927-May-04 10:26 
GeneralDataset XML Diff Pin
MrJJKoolJ27-May-04 8:42
MrJJKoolJ27-May-04 8:42 
Hi,

I am getting a root element is missing when I try to read in the xml diffram from file. Also one key note I am using the compact framework which doesn't support Typed datasets. Cry | :((

Heres the code that I am trying out:

<br />
<br />
public static DataSet GetMyXmlDS(string sXmlFileName, string sPath ) <br />
		{<br />
			string sFileName = sPath + @"\MidnightData.xml";<br />
			string sFileName2 = sPath + @"\MidnightRead2.xsd";<br />
<br />
			<br />
			DataSet IpacDS = new DataSet("Table1");<br />
			<br />
			try<br />
			{<br />
				<br />
				SqlConnection myCon = new SqlConnection();<br />
				myCon.ConnectionString = sCon1;<br />
				SqlDataAdapter da = new SqlDataAdapter(@"Select * From MidnightReadings WHERE MR_Date = '12/1/2003'", myCon);<br />
<br />
				da.Fill(IpacDS);<br />
<br />
				FileStream myFileStream = new System.IO.FileStream<br />
					(sFileName, FileMode.OpenOrCreate);<br />
<br />
				XmlTextWriter myXmlWriter = <br />
					new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);<br />
<br />
				IpacDS.WriteXml(myXmlWriter, XmlWriteMode.DiffGram);<br />
				IpacDS.WriteXmlSchema(sFileName2);<br />
<br />
			//	myXmlWriter.Close();<br />
<br />
				XmlTextReader myXmlTextRead = <br />
					new System.Xml.XmlTextReader(myFileStream);<br />
<br />
			   <br />
			//	IpacDS.ReadXmlSchema(sFileName2);<br />
				IpacDS.ReadXml(myXmlTextRead);<br />
			<br />
				return IpacDS;<br />
<br />
			}<br />
			catch (SqlException e) <br />
			{<br />
				string errorMessage = "Message: " + e.Message + "\n" +<br />
					"Source: " + e.Source + "\n" +<br />
					"State: " + e.State + "\n" +<br />
					"Procedure: " + e.Procedure + "\n";<br />
				MessageBox.Show(errorMessage,"Error in DataCon");<br />
			<br />
				return IpacDS;<br />
			}<br />
			catch (XmlException xe) <br />
			{<br />
				string errorMessage = "Message: " + xe.Message + "\n" ;<br />
				MessageBox.Show(errorMessage,"Error in DataCon");<br />
			<br />
				return IpacDS;<br />
			}	<br />
<br />
		}<br />
<br />


Xml dataset :

<br />
<br />
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><br />
<Table1><Table diffgr:id="Table1" msdata:rowOrder="0"><br />
<MR_ID>110</MR_ID><br />
<MR_Date>2003-12-01T00:00:00.0000000-05:00</MR_Date><br />
<Coal_Feeder_Tot>690058</Coal_Feeder_Tot><br />
<Coal_Silo_Level_Prct>73</Coal_Silo_Level_Prct><br />
<Coal_Barn_Inv_Prct>25</Coal_Barn_Inv_Prct><br />
<Limestone_Feed_Total>171316</Limestone_Feed_Total><br />
<LS_Silo_Level_Prct>70</LS_Silo_Level_Prct><br />
<Ammonia_Totalizer>388974</Ammonia_Totalizer><br />
<Prop_to_Burn_Totalizer>14629</Prop_to_Burn_Totalizer><br />
<TwentyFourHr_SO2_Reduct>92</TwentyFourHr_SO2_Reduct><br />
<Limestone_Received>40800.37</Limestone_Received><br />
<Ammonia_Received>0</Ammonia_Received><br />
<Prop_Received>9004</Prop_Received><br />
<Est_hours_Dry_Oper_Hours>0</Est_hours_Dry_Oper_Hours><br />
<LAB_Sulfur_Content_Prct>2.13</LAB_Sulfur_Content_Prct><br />
<LAB_High_Heat_Val>6833</LAB_High_Heat_Val><br />
<CEMS_SO2_Daily_Avg>549</CEMS_SO2_Daily_Avg><br />
<Raw_Water_Pump_Meter>15795967</Raw_Water_Pump_Meter><br />
<Reservoir_Level>1844</Reservoir_Level><br />
<Date_Rec_Added>2003-12-08T08:47:15.0000000-05:00</Date_Rec_Added><br />
</Table></Table1><br />
</diffgr:diffgram><br />
<br />


Now what gets me is that as you can see in the code. I am writing the dataset to file and a schema to file. Then I turn right around and try reading it in but fails on the ReadXML statement. I have tried reading in the Schema file into dataset first and then without reading in schema. Any ideas?

Thanks,

JJ
GeneralRe: Dataset XML Diff Pin
Dave Kreskowiak27-May-04 9:50
mveDave Kreskowiak27-May-04 9:50 
GeneralInserting SQLSever rows Pin
ABean27-May-04 8:41
ABean27-May-04 8:41 
GeneralRe: Inserting SQLSever rows Pin
Heath Stewart27-May-04 10:01
protectorHeath Stewart27-May-04 10:01 
GeneralRe: Inserting SQLSever rows Pin
Andy Brummer27-May-04 10:07
sitebuilderAndy Brummer27-May-04 10:07 
GeneralHot Keys on Tab Page Text Pin
UTRocketFan27-May-04 7:55
UTRocketFan27-May-04 7:55 
GeneralRe: Hot Keys on Tab Page Text Pin
Heath Stewart27-May-04 8:19
protectorHeath Stewart27-May-04 8:19 
Generaldeploying assembly Pin
Ammar Ben Hadj Amor27-May-04 7:40
professionalAmmar Ben Hadj Amor27-May-04 7:40 
GeneralRe: deploying assembly Pin
Heath Stewart27-May-04 8:14
protectorHeath Stewart27-May-04 8:14 
GeneralBinding.Format to a Datagrid Column Pin
Anfernius27-May-04 7:11
Anfernius27-May-04 7:11 
GeneralRe: Binding.Format to a Datagrid Column Pin
Heath Stewart27-May-04 8:12
protectorHeath Stewart27-May-04 8:12 
GeneralRe: Binding.Format to a Datagrid Column Pin
Anfernius27-May-04 8:32
Anfernius27-May-04 8:32 
GeneralRe: Binding.Format to a Datagrid Column Pin
Heath Stewart27-May-04 8:35
protectorHeath Stewart27-May-04 8:35 
GeneralClosing a Worker Thread when Dialog Closes Pin
Guinness4Strength27-May-04 5:37
Guinness4Strength27-May-04 5:37 
GeneralRe: Closing a Worker Thread when Dialog Closes Pin
scadaguy27-May-04 10:44
scadaguy27-May-04 10:44 
GeneralRe: Closing a Worker Thread when Dialog Closes Pin
Guinness4Strength27-May-04 10:48
Guinness4Strength27-May-04 10:48 
GeneralPorting from C# to VC++ Pin
Prakash Nadar27-May-04 5:09
Prakash Nadar27-May-04 5:09 
GeneralRe: Porting from C# to VC++ Pin
Guinness4Strength27-May-04 5:46
Guinness4Strength27-May-04 5:46 

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.