473,666 Members | 2,105 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 =
ConfigurationSe ttings.AppSetti ngs["AlreadySentTim eSheetsDataSet"];
if ( !File.Exists( sFile ) )
return;

DataSet ds = new DataSet();
ds.ReadXml(sFil e);
if (ds.Tables.Coun t 0)
if ( ds.Tables[0] != null)
for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++)
_alreadySentTim eSheets.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 5984
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="ExceptionLo gDS"
targetNamespace ="http://tempuri.org/ExceptionLogDS. xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d"
xmlns="http://tempuri.org/ExceptionLogDS. xsd"
xmlns:mstns="ht tp://tempuri.org/ExceptionLogDS. xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="Exception LogDS" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Exception ">
<xs:complexType >
<xs:sequence>
<xs:element name="Exception Message" type="xs:string " minOccurs="0" />
<xs:element name="Exception Type" type="xs:string " minOccurs="0" />
<xs:element name="Exception DateTime" type="xs:dateTi me" 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 SaveErrorDataSe t(ExceptionLogD S ds , Exception ex)
{
if (null!=ds)
{
string uuid = System.Guid.New Guid().ToString ();
string xmlfileName = uuid + ".xml";
string exceptionFileNa me = uuid + ".log";
if (this.m_errorOu tputDirectory.L ength 0 )
{
if (!System.IO.Dir ectory.Exists(t his.m_errorOutp utDirectory))
{
System.IO.Direc tory.CreateDire ctory(this.m_er rorOutputDirect ory);
}
xmlfileName = this.m_errorOut putDirectory + @"\" + xmlfileName;
exceptionFileNa me = this.m_errorOut putDirectory + @"\" +
exceptionFileNa me;
}
ds.WriteXml(xml fileName);

DataSets.Except ionLogDS exDS = new
GranadaCoder.Ap plications.Bulk DataTransferExa mple.DataSets.E xceptionLogDS
();
exDS.Exception. AddExceptionRow (ex.Message , ex.GetType().To String() ,
DateTime.Now );
exDS.WriteXml(e xceptionFileNam e);


}
}
"Sathyaish" <sa*******@gmai l.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.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
8703
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 ds2 = (DataSet)formatter2.Deserialize(stream2); For the size of my DataSet, its taking 0.8 seconds to serialize and 2.3 seconds to deserialize.
35
2117
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; namespace TestNamespace {
2
2190
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
4218
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 SQL table? Is there a short way like the FILL method to get data into the dataset or do I have to read each datarow in the table and write it one at the time to the
9
12974
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 northwind database that has an employees, orders, and order details. the following are the 3 tables in my sql database students schyrsem
3
1926
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
2515
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 others. One of the custom format is as follows: dsmessages_dt.Columns.Add("Image", GetType(Image)) I had a problem of when I used a checkbox in the grid that was bound to the datatable that it would not update my dataset. So I created another...
2
4690
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 tables in one call. I'm using Microsoft EnterpriseLibrary for Data to get the data from SP. It works fine and I get two tables in the dataset, "Table1" and "Table2". I then have an XML-file, which will serve as a template to generate the XML-schema,...
5
1533
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 data-bound to 9 combo boxes. Following selection of items in the combo boxes and the click of a button, the results are then manually written back to the first table in dataset1. The problem that I am having is that after the selection in the first combo...
3
2151
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 suggest using .clone() and .copy(). Neither results in a different error. Within another class, I've gathered two tables of data for a nested repeater. To return a table, int, string or anything else in C#, one sets their local variable equal...
0
8449
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8556
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8642
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2774
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1777
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.