HOW GET DATE IN C# DATETIMEPICKER CONTROL

Kenny Tangnde

Total Post:68

Points:476
Posted by  Kenny Tangnde
C# 
C#
 7175  View(s)
Ratings:
Rate this:

Hi All,

    I encountered some problems, See details below:

how get date in c# dateTimePicker control,i need date only.such as:2011-10-15 (yyyy-month-day).

Can not immediately update the data in treeView1_NodeMouseClick event.

see code below:

private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            dataGridView1.DataSource = "";  
         try
            {
              
                string AccessAddress = System.IO.Path.GetFullPath("PSRecord.mdb");
                //con = new OleDbConnection(@"provider=microsoft.ace.oledb.12.0;persist securityInfo=false;data source=" + AccessAddress);
                con = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0;data source=" + AccessAddress);
                con.Open();
                cmd = new OleDbCommand("select * from Record  where driver='" + treeView1.SelectedNode.Text.ToString() + "'", con);
                ds = new DataSet();
                adapter = new OleDbDataAdapter(cmd);
                adapter.Fill(ds);
                dataGridView1.DataSource = ds.Tables[0];

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }
            finally
            {
                con.Close();
            }
        }

i need help now,Thanks!

  1.   Modified On Oct-28-2016 04:41:30 AM
  1. Kenny Tangnde

    Post:68

    Points:476
    Re: how get date in c# dateTimePicker control

    Hi Uttam Misra,

      You help me to solve the first problem, the problem is now the second left.

    thanks for your help.

  1. Kenny Tangnde

    Post:68

    Points:476
    Re: how get date in c# dateTimePicker control

    I have a problem,client run my program error occurred,Error content is:The 'microsoft.jet.oledb.4.0' provider is not registered on the local machine.

    Code is as follows:

    private void frmMain_Load(object sender, EventArgs e)
            {
                string AccessAddress=System.IO.Path.GetFullPath("PSRecord.mdb");
                //con = new OleDbConnection(@"provider=microsoft.ace.oledb.12.0;persist securityInfo=false;data source=" + AccessAddress);
                con = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0;data source=" + AccessAddress);
                con.Open();
                cmd = new OleDbCommand("select drivername from driver", con);
                reader = cmd.ExecuteReader();
                TreeNode parent = treeView1.Nodes.Add("DriverName");
                TreeNode child;
                parent.ForeColor = Color.Red;
                while (reader.Read())
                {
                   //comboBox1.Items.Add(reader["DriverName"]);
                   child = parent.Nodes.Add(reader.GetValue(0).ToString());
                   child.ForeColor = Color.Blue;
     
                }
                parent.ExpandAll();
                reader.Close();
                con.Close();


            }

     

    thanks very much.

  1. Uttam Misra

    Post:126

    Points:906
    Re: how get date in c# dateTimePicker control

    are you working with 64bit system?

  1. Kenny Tangnde

    Post:68

    Points:476
    Re: how get date in c# dateTimePicker control

    client system is XP sp2

  1. Uttam Misra

    Post:126

    Points:906
    Re: how get date in c# dateTimePicker control


    Are you running your application on x64 or x86 version of Windows?

      Modified On Oct-15-2011 01:56:31 AM
  1. Kenny Tangnde

    Post:68

    Points:476
    Re: how get date in c# dateTimePicker control

    Where to set?

  1. Uttam Misra

    Post:126

    Points:906
    Re: how get date in c# dateTimePicker control

    To resolve this issue open the project in Visual Studio :

    1. From the solution explorer right-click your project then click Properties
    2. Click the Build tab
    3. Change Platform target from: Any CPU to x86
    4. Re-build your solution

  1. Kenny Tangnde

    Post:68

    Points:476
    Re: how get date in c# dateTimePicker control

    x86 can run it in XP sp2 environment?

    thanks!

  1. John Smith

    Post:103

    Points:727
    Re: how get date in c# dateTimePicker control

    you got it ...is it working now?

      Modified On Oct-15-2011 05:02:23 AM
  1. Alex R

    Post:40

    Points:280
    Re: how get date in c# dateTimePicker control

    Hi Aken H,

    It is always a good habbit to ask someone if you get stuck some where, and I appretiate you do so to get your queries solved. But I have a suggestion for you so that you can get your answer more quickly.

    Please do make sure that if you have more than one query always start a seperate thread for each problem so that each of your problem get noticed individually.

    Hope, you got all your problems solved here and you will be following the the suggestions provided above in near future.

    Thanks.

  1. Kenny Tangnde

    Post:68

    Points:476
    Re: how get date in c# dateTimePicker control

    Hi Haider M Rizvi,

    Thank you for reminding me, i will correct.

     

    Thanks.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!