i have a form in which am displaying data in datagridview from DB & i also have a textbox in which am able to autocomplete strings of other columns and search in datagridview and get the matching data filtered and displayed in datagridview but not able to do that for date column
how to do autocomplete for date alone [not with time] in textbox in required format "dd-mm-yyyy" and fetch the matching date column to display in datagriview
i have tried the below code but it doesn't works
AutoCompleteStringCollection ACSCVV = new AutoCompleteStringCollection();
OLCMND3 = new OracleCommand("Select to_date(to_char(TODAYDATE, 'dd-mm-yyyy'),'dd-mm-yyyy HH:MI:SS') as TODAYDATE from TABLENAME order by NUMBER asc", CON);
DR1 = OLCMND3.ExecuteReader();
if (DR1.HasRows == true)
{
while (DR1.Read())
{
ACSCVV.Add(DR1["TODAYDATE"].ToString());
}
}
else
{
MessageBox.Show("No Data Present In The Database");
}
DR1.Close();
TypeHereTextBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
TypeHereTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
TypeHereTextBox.AutoCompleteCustomSource = ACSCVV;
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Iftikar HussainPosted Aug 13, 2013, 2:24 AM
AutoComplete works only with string datatype. So you need to treat your date value as string while typing the value in the textbox. As you said time is not required then do like this
OLCMND3 = new OracleCommand("Select to_char(TODAYDATE, 'dd-mm-yyyy') as DateData from TABLENAME order by NUMBER asc", CON);
Regards,
Iftikar
kumartyrPosted Aug 13, 2013, 2:18 AM
Sanjeeb LenkaPosted Aug 13, 2013, 1:47 AM
you can try this query
Select to_char(TODAYDATE, 'dd-mm-yyyy') as TODAYDATE from TABLENAME