473,508 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSet.Tables[0]

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.

Sep 1 '06 #1
2 5974
Please ignore this question. There was an error in my XML. I was too
much in a hurry to post this question before checking.

Sep 1 '06 #2

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_errorOutputDir ectory))
{
System.IO.Directory.CreateDirectory(this.m_errorOu tputDirectory);
}
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" <sa*******@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
Please ignore this question. There was an error in my XML. I was too
much in a hurry to post this question before checking.

Sep 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8692
by: hs | last post by:
Hi I am serializing a dataset using a binary formatter as follows: IFormatter formater = new BinaryFormatter(); formatter.Serialize(stream, ds); // ds=DataSet, stream=MemoryStream .... DataSet...
35
2087
by: MuZZy | last post by:
Hi All, I got a issue here and hope someone can help me: Let's consider this code: // =================== CODE START ================================= using System; using System.Data; ...
2
2178
by: shine | last post by:
I want to retrieve first 3 records of first table and last 4 records of second table, How to do this using c# and dataset? Any suggestion would be greatly appretiated
22
4203
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty...
9
12953
by: jaYPee | last post by:
I have search a lot of thread in google newsgroup and read a lot of articles but still i don't know how to update the dataset that has 3 tables. my 3 tables looks like the 3 tables from...
3
1918
by: jcrouse | last post by:
I have the following code that creates a couple of XML files: Dim dt1 As New DataTable("P1JoyUp") If H = True Then Dim dsH As New DataSet("HCPViewer") dsH.Tables.Add(dt1)
3
2505
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
2
4684
by: Henrik | last post by:
Hi, I'm really stuck with this one. I have a dataset with two tables. One table is company data, and the other is contacts. I populate these by using a SP in SQL Server which returns the two...
5
1525
by: mydogisbox | last post by:
I have two datasets. One dataset table from dataset1 is bound to a list box. On selection in the list box dataset2 has 9 tables that are populated from the database. these tables are then...
3
2141
by: leviwatts | last post by:
Exception Details: System.ArgumentException: DataTable already belongs to another DataSet. Googling for this error shows several post of people trying to manipulate a table within a dataset. Others...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7405
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.