I am trying to fetch Date, Month and Year separately from date column in Access Database.
I am using following code for it.
I don't know what is the problem with this, but either it shows me error or no data is returned.
I am new to OLEDB so I don't know if it is possible or not.
Please help.
And please show me alternatives if this way is incorrect.
conn_string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\MHV\Documents\Visual Studio 2012\Projects\UTS\UTS.mdb"
conn = New OleDbConnection(conn_string)
conn.Open()
Grid_string = "SELECT datepart(mm,T_Date) from Transactions"
Grid_cmd = New OleDbCommand(Grid_string, conn)
RW_AD = New OleDbDataAdapter(Grid_cmd)
Grid_DS = New DataSet
Grid_cmd.Connection = conn
Grid_cmd.CommandText = Grid_string
RW_AD.Fill(Grid_DS, "Transactions")
Grid_cmd.ExecuteNonQuery()
DataGridView1.DataSource = Grid_DS.Tables("Transactions").DefaultView
P.S. : Connection and other things are working fine. It only shows me error when I use datepart().