How to Work with date data types in ODBC in .NET

Viewed 21

I am working on .NET project where i am trying to retrieve the specific rows from a table having name itemmovementanalysis having a column named lastsaledate which shows products last sale date having data type of date. I am trying to retrieve the data from this date column by using ODBC in .NET but I am unable to retrieve it. I have tried many things but unfortunately unable to do so. Below is my code

private void listBox1_DoubleClick(object sender, EventArgs e)
    {
        if (listBox1.SelectedItem != null)
        {
            DialogResult dr = MessageBox.Show("Showing data of Table " + listBox1.SelectedItem.ToString(), "Title", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (dr == DialogResult.Yes)
            {
                using (OdbcConnection con = new OdbcConnection(source)) 
                {
                    string query = " SELECT $_ClosingBalance, $_InwardQuantity, $_LastPurcDate,$_LastPurcQty,$_LastSaleDate,$_LastSaleParty,$_LastSalePrice,$_LastSaleQty,$_OutwardQuantity,$Name,$Parent from " + listBox1.SelectedItem.ToString() + " where $_LastSaleDate =  '2022-09-08'   ";
                  
                    using (OdbcDataAdapter dadapter = new OdbcDataAdapter(query, con)) 
                    {
                        DataTable table = new DataTable();
                        dadapter.Fill(table);
                        this.dataGridView1.DataSource = table;
                    }
                }



            }
        }
0 Answers
Related