I am working on a project in which i've to identify a textbox value,

The end user may enter a date (dd\mm\yyyy) or may enter a ticket number (alphanumeric:ex:'VD103'),

can anyone tell me how to distinguish the date or string values entered in the textbox so that depending upon that i am able to connect to the database


you can use Datetime.ParseExact

Show me your work to get more.

commented: Nice suggestion. +6

My code looks like this
I've used the datetime.exactparse to distinguish between date and string
error is that we cannot use
DateTime.ParseExact(strByDateByTkt, strformat, CultureInfo.InvariantCulture) as a bool type

what should i do

public void btnByDayByTktGo_Click(object sender, EventArgs e)
        objCommon = new HDCommon();
        string strVenName = ddlVenTktLog.SelectedValue.ToString().Trim(),
               strStatus = ddlVenTktStatus.SelectedValue.ToString().Trim(),
               strByDateByTkt = txtVenTktSrchByDayByTkt.Text.ToString().Trim(),
               strMode = "C",

     if ((DateTime.ParseExact(strByDateByTkt, strformat, CultureInfo.InvariantCulture)))
                BindGrid(strVenName, strStatus, "", "", strMode,                                
                      objCommon.DateFormat(strByDateByTkt,"MM/DD/YYYY"), "");
            BindGrid(strVenName, strStatus, "", "", strMode, strByDateByTkt, "");

I have no clue what you are trying to do.

Please use code tagging.

if (DateTime.Compare(DateTime.ParseExact(strByDateByTkt, strformat, System.Globalization.CultureInfo("en-US")), new DateTime(2010, 03, 15)) == 0))

==0 means the date is equal
< 0 means the right date is less than the left date
> 0 meand the right date is higher than the right date.