PC Review


Reply
Thread Tools Rate Thread

DataSet.Tables[0]

 
 
Sathyaish
Guest
Posts: n/a
 
      1st Sep 2006
We are required to send our weekly timesheets by Friday morning. I
sometimes forget to send them until Friday evening, if I am reminded,
or by the next Monday.

To solve my problem, I am writing a quick and dirty utility that will
mail timesheets out of a specific folder every Friday 9 AM whether I am
on my seat or not. It's fun.

I am keeping the list of timesheet files I have already sent in an XML
file. On program start up, I load it into a dataset and then into a
hashtable and then I dispose the dataset. Here's the code snippet under
discussion:


string sFile =
ConfigurationSettings.AppSettings["AlreadySentTimeSheetsDataSet"];
if ( !File.Exists( sFile ) )
return;

DataSet ds = new DataSet();
ds.ReadXml(sFile);
if (ds.Tables.Count > 0)
if ( ds.Tables[0] != null)
for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++)
_alreadySentTimeSheets.Add(ds.Tables[0].Rows[i][0],
ds.Tables[0].Rows[i][0]);


The problem is that the dataset does not contain any tables. The XML
file does have 25 records and is well formed and valid.

 
Reply With Quote
 
 
 
 
Sathyaish
Guest
Posts: n/a
 
      1st Sep 2006
Please ignore this question. There was an error in my XML. I was too
much in a hurry to post this question before checking.

 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      1st Sep 2006

I would still create a "strongly typed dataset" object.

They're easier to deal with.


HEre is one I use:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ExceptionLogDS"
targetNamespace="http://tempuri.org/ExceptionLogDS.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://tempuri.org/ExceptionLogDS.xsd"
xmlns:mstns="http://tempuri.org/ExceptionLogDS.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="ExceptionLogDS" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Exception">
<xs:complexType>
<xs:sequence>
<xs:element name="ExceptionMessage" type="xs:string" minOccurs="0" />
<xs:element name="ExceptionType" type="xs:string" minOccurs="0" />
<xs:element name="ExceptionDateTime" type="xs:dateTime" minOccurs="0"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>


the the code to add new entries:

mine is kludgey, but shows simple WriteXml methods.


private void SaveErrorDataSet(ExceptionLogDS ds , Exception ex)
{
if (null!=ds)
{
string uuid = System.Guid.NewGuid().ToString();
string xmlfileName = uuid + ".xml";
string exceptionFileName = uuid + ".log";


if (this.m_errorOutputDirectory.Length > 0 )
{
if (!System.IO.Directory.Exists(this.m_errorOutputDirectory))
{
System.IO.Directory.CreateDirectory(this.m_errorOutputDirectory);
}


xmlfileName = this.m_errorOutputDirectory + @"\" + xmlfileName;
exceptionFileName = this.m_errorOutputDirectory + @"\" +
exceptionFileName;
}
ds.WriteXml(xmlfileName);

DataSets.ExceptionLogDS exDS = new
GranadaCoder.Applications.BulkDataTransferExample.DataSets.ExceptionLogDS
();
exDS.Exception.AddExceptionRow(ex.Message , ex.GetType().ToString() ,
DateTime.Now );
exDS.WriteXml(exceptionFileName);




}
}


"Sathyaish" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Please ignore this question. There was an error in my XML. I was too
> much in a hurry to post this question before checking.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSet has no tables Jeremy Microsoft ADO .NET 1 6th Jul 2009 09:52 AM
DataSet Designer/adding multiple tables to a dataset/ how? =?Utf-8?B?Q3VydGlz?= Microsoft ADO .NET 1 21st Aug 2006 02:09 PM
How to update dataset.Tables["tab1"] from records in dataset.Tables["tab2"]? AndiSHFR Microsoft C# .NET 1 12th Jan 2006 06:41 AM
dataset tables juli jul Microsoft C# .NET 0 20th Mar 2005 11:08 AM
DataSet Tables into Access tables with Oledb? Nevyn Twyll Microsoft ADO .NET 6 2nd Sep 2004 08:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:03 AM.