Datatable help class

Source: Internet
Author: User

Using system;
Using system. Collections. Generic;
Using system. text;
Using system. Data;
Using system. Data. sqlclient;
Using Microsoft. Office. InterOP. Excel;
Using Microsoft. Office. InterOP. word;
Using system. collections;
Using system. IO;
Namespace common
{
Public class datasetoperation
{
String exceptionmessage; // defines the exception information.
Datasetoperation ()
{
}

# Region connects two able with the same data structure and returns the datatable
/// <Summary>
/// Connect two able with the same data structure and return the datatable
/// </Summary>
/// <Param name = "Table1"> </param>
/// <Param name = "Table2"> </param>
/// <Returns> </returns>
Public System. Data. datatable getinnerdatatable (system. Data. datatable Table1, system. Data. datatable table2)
{
Table1.merge (table2 );
Return Table1;
}
// Write the dataset to an XML file
Public bool writedatasettoxml (Dataset dataset, string filename)
{
Try
{
Dataset. writexml (filename );
Return true;
}
Catch (exception ex)
{
Predictionmessage = ex. message;
Return false;
}
}
# Endregion

# Region Query data in a datatable
/// <Summary>
/// Query the data in the datatable
/// </Summary>
/// <Param name = "table"> datatable to be queried </param>
/// <Param name = "comtext"> query condition </param>
/// <Returns> data column set </returns>
Public datarow [] getselectdatatable (system. Data. datatable table, string comtext)
{
Try
{
Datarow [] rows = table. Select (comtext );
Return rows;
}
Catch (exception ex)
{
Predictionmessage = ex. message;
Return NULL;
}
}
# Endregion

# Region setting or getting exception information
/// <Summary>
/// Set or obtain exception information
/// </Summary>
Public String exceptionmessage
{
Get
{
Return exceptionmessage;
}
Set
{
Predictionmessage = value;
}
}
# Endregion
}
}

 

Note:ArticleReprinted to Bai yixuan

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.