C # accessSQL query date code!

Source: Internet
Author: User
C # accessSQL query date code! Note: In ACCESS, the Date type is in the format of privatevoidFindButton_Click (objectsender, EventArgse) {OleDbConnectionconnewOleDbConnection (dbConnetion. connetion); In dbConnetion. cs

C # access SQL query date code! Note: The Date type in ACCESS is like: long Date type private void FindButton_Click (object sender, EventArgs e) {OleDbConnection con = new OleDbConnection (dbConnetion. connetion); // In dbConnetion. cs has

C # access SQLQueryDateOfCode!

Note: In ACCESS, the Date type is like the length.DateType

Private void FindButton_Click (object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection (dbConnetion. connetion); // There is a special data opening class in dbConnetion. cs.
String reverse STR;
If (Hour = 0)
{
Explain STR = "select * from MeteorologyData where Date =" + this. FindDate. ToOADate ();

}
Else
{
Explain STR = "select * from MeteorologyData where Date =" + this. FindDate. ToOADate () + "and Time =" + Hour;
}
Con. Open ();

OleDbDataAdapter adp = new OleDbDataAdapter (reverse STR, con );
Ds = new DataSet ();
Ds. Clear ();
Adp. Fill (ds );
String [] mytitle = {"Date"," Time period "," effective visibility "," sea level visibility "," weather phenomenon "," total cloud volume "," medium and low cloud volume "," low cloud volume ", "Cloud code", "Cloud", "wind direction", "Wind Speed", "temperature", "absolute humidity", "relative humidity", "Dew Point", "pressure on this site ", "sea level pressure", "precipitation", "wave", "recorder number "};
For (int I = 0; I {
Ds. Tables [0]. Columns [I]. ColumnName = mytitle [I];
}

DataGridView1.DataSource = ds. Tables [0]. DefaultView;

// DataGridView1.Capture = "Total" + ds. Tables [0]. Rows. Count. ToString () + "record ";
Con. Close ();
}


Article:C # access SQLQueryDateOfCode!
Address: http://www.verydemo.com

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.