at runtime if user type in the above format in the textbox ..it will fetch the matching rows of data for the specified date and filter that and show in datagridview
so for that i want to compare the date format with the text typed in textbox
string todaydate = Convert.ToString(DateTime.Today);
DateTime DTM = Convert.ToDateTime(Date);
string datetoday = DTM.ToString("dd-MMM-yyyy");
if (TypeHereTextBox.Text == datetoday)
{
OLCMND2 = new OracleCommand("Select * from TABLENAME where DATE = '" + TypeHereTextBox.Text + "'", CON);
OADAP1 = new OracleDataAdapter(OLCMND2);
OADAP1.Fill(DTBLE2);
DatagridView.DataSource = DTBLE2;
}
how can it be solved
Iftikar HussainPosted Aug 14, 2013, 8:41 AM
string[] arrayData = TypeHereTextBox.Text.Split('-');
if (TypeHereTextBox.Text == "") {
messagebox.shw(empty)
else if(arrayData.Length == 3) // i ma considering the date value will be always in dd-MMM-YYYY formar
{
OLCMND2 = new OracleCommand("Select PASSNUMBER,REGISTERINFO,GENDER,TIMEIN,FIRSTNAME,LASTNAME,PHONENUMBER,EMAILID,VEHICLENUMBER,ADDRESSLINE1,ADDRESSLINE2,CITY,PINCODE,COMPANYNAME,PURPOSE,VISITORTYPE,TOMEET,DEPARTMENT,TIMEOUT,VISITORCOUNT,REMARKS,to_date(to_char(TODAYDATE, 'DD-MON-YYYY'),'DD-MON-YYYY') AS TODAYDATE,CARDNUMBER,PHOTO from VMS_VISITOR where TODAYDATE = TO_DATE('" + TypeHereTextBox.Text + "','dd-MON-yyyy')", CON);
OADAP1 = new OracleDataAdapter(OLCMND2);
OADAP1.Fill(DTBLE2);
VisitorReportView.DataSource = DTBLE2;
}
else
{
OLCMND4 = new OracleCommand("Select PASSNUMBER,REGISTERINFO,GENDER,TIMEIN,FIRSTNAME,LASTNAME,PHONENUMBER,EMAILID,VEHICLENUMBER,ADDRESSLINE1,ADDRESSLINE2,CITY,PINCODE,COMPANYNAME,PURPOSE,VISITORTYPE,TOMEET,DEPARTMENT,TIMEOUT,VISITORCOUNT,REMARKS,TODAYDATE,CARDNUMBER,PHOTO from VMS_VISITOR where PASSNUMBER ='" + TypeHereTextBox.Text +
"'or REGISTERINFO = '" + TypeHereTextBox.Text + "'or GENDER = '" + TypeHereTextBox.Text + "'or TIMEIN = '" + TypeHereTextBox.Text +
"'or FIRSTNAME = '" + TypeHereTextBox.Text + "'or LASTNAME = '" + TypeHereTextBox.Text + "'or PHONENUMBER = '" + TypeHereTextBox.Text +
"'or EMAILID = '" + TypeHereTextBox.Text + "'or VEHICLENUMBER = '" + TypeHereTextBox.Text + "'or ADDRESSLINE1 = '" + TypeHereTextBox.Text +
"'or ADDRESSLINE2 = '" + TypeHereTextBox.Text + "'or CITY = '" + TypeHereTextBox.Text + "' or PINCODE = '" + TypeHereTextBox.Text +
"'or COMPANYNAME = '" + TypeHereTextBox.Text + "'or PURPOSE = '" + TypeHereTextBox.Text + "'or VISITORTYPE = '" + TypeHereTextBox.Text +
"'or TOMEET = '" + TypeHereTextBox.Text + "'or DEPARTMENT = '" + TypeHereTextBox.Text + "'or TIMEOUT = '" + TypeHereTextBox.Text +
"'or VISITORCOUNT = '" + TypeHereTextBox.Text + "'or REMARKS = '" + TypeHereTextBox.Text + "' or CARDNUMBER ='" + TypeHereTextBox.Text + "'", CON);
}
OADAP2 = new OracleDataAdapter(OLCMND4);
OADAP2.Fill(DTBLE2);
VisitorReportView.DataSource = DTBLE2;
}
con.close();
Regards,
Iftikar
Iftikar HussainPosted Aug 16, 2013, 1:23 AM
Regards,
Iftikar
kumartyrPosted Aug 16, 2013, 1:18 AM
i have done a mistake in the oracle statement so that why i got this exception again after trying with your suggested code
now its works great with your code !!!!
thanks you so much for timely help Iftikar
Iftikar HussainPosted Aug 16, 2013, 1:03 AM
else
{
OLCMND4 = new OracleCommand("Select PASSNUMBER,REGISTERINFO,GENDER,TIMEIN,FIRSTNAME,LASTNAME,PHONENUMBER,EMAILID,VEHICLENUMBER,ADDRESSLINE1,ADDRESSLINE2,CITY,PINCODE,COMPANYNAME,PURPOSE,VISITORTYPE,TOMEET,DEPARTMENT,TIMEOUT,VISITORCOUNT,REMARKS,TODAYDATE,CARDNUMBER,PHOTO from VMS_VISITOR where PASSNUMBER ='" + TypeHereTextBox.Text +
"'or REGISTERINFO = '" + TypeHereTextBox.Text + "'or GENDER = '" + TypeHereTextBox.Text + "'or TIMEIN = '" + TypeHereTextBox.Text +
"'or FIRSTNAME = '" + TypeHereTextBox.Text + "'or LASTNAME = '" + TypeHereTextBox.Text + "'or PHONENUMBER = '" + TypeHereTextBox.Text +
"'or EMAILID = '" + TypeHereTextBox.Text + "'or VEHICLENUMBER = '" + TypeHereTextBox.Text + "'or ADDRESSLINE1 = '" + TypeHereTextBox.Text +
"'or ADDRESSLINE2 = '" + TypeHereTextBox.Text + "'or CITY = '" + TypeHereTextBox.Text + "' or PINCODE = '" + TypeHereTextBox.Text +
"'or COMPANYNAME = '" + TypeHereTextBox.Text + "'or PURPOSE = '" + TypeHereTextBox.Text + "'or VISITORTYPE = '" + TypeHereTextBox.Text +
"'or TOMEET = '" + TypeHereTextBox.Text + "'or DEPARTMENT = '" + TypeHereTextBox.Text + "'or TIMEOUT = '" + TypeHereTextBox.Text +
"'or VISITORCOUNT = '" + TypeHereTextBox.Text + "'or REMARKS = '" + TypeHereTextBox.Text + "' or CARDNUMBER ='" + TypeHereTextBox.Text + "'", CON);
}
and also share the table column datatype
Regards,
Iftikar
kumartyrPosted Aug 16, 2013, 1:00 AM
i tried as per your sugestion but i got the same exception which i have been getting before started asking in this thread
the exception is
ora-01858 a non-numeric character was found where a numeric was expected
you also have seen my code...
can tell me what may be the reason for this exception ..
kumartyrPosted Aug 14, 2013, 8:10 AM
{
if
am using .net 2.0 and oracle 11g
please see the zip i have attached
Iftikar HussainPosted Aug 14, 2013, 7:35 AM
else if(typeheretextbox.text == date.format [which is what i want])
{
kumartyrPosted Aug 14, 2013, 7:23 AM
i have to check
1.if the textbox is empty do this
2.date
3.other columns
i think if you see my code u will understand
con.open();
DTBLE2 = new DataTable();
if (TypeHereTextBox.Text == "") {
messagebox.shw(empty)
else if(typeheretextbox.text == date.format [which is what i want])
{
OLCMND2 = new OracleCommand("Select PASSNUMBER,REGISTERINFO,GENDER,TIMEIN,FIRSTNAME,LASTNAME,PHONENUMBER,EMAILID,VEHICLENUMBER,ADDRESSLINE1,ADDRESSLINE2,CITY,PINCODE,COMPANYNAME,PURPOSE,VISITORTYPE,TOMEET,DEPARTMENT,TIMEOUT,VISITORCOUNT,REMARKS,to_date(to_char(TODAYDATE, 'DD-MON-YYYY'),'DD-MON-YYYY') AS TODAYDATE,CARDNUMBER,PHOTO from VMS_VISITOR where TODAYDATE = TO_DATE('" + TypeHereTextBox.Text + "','dd-MON-yyyy')", CON);
OADAP1 = new OracleDataAdapter(OLCMND2);
OADAP1.Fill(DTBLE2);
VisitorReportView.DataSource = DTBLE2;
}
else
{
OLCMND4 = new OracleCommand("Select PASSNUMBER,REGISTERINFO,GENDER,TIMEIN,FIRSTNAME,LASTNAME,PHONENUMBER,EMAILID,VEHICLENUMBER,ADDRESSLINE1,ADDRESSLINE2,CITY,PINCODE,COMPANYNAME,PURPOSE,VISITORTYPE,TOMEET,DEPARTMENT,TIMEOUT,VISITORCOUNT,REMARKS,TODAYDATE,CARDNUMBER,PHOTO from VMS_VISITOR where PASSNUMBER ='" + TypeHereTextBox.Text +
"'or REGISTERINFO = '" + TypeHereTextBox.Text + "'or GENDER = '" + TypeHereTextBox.Text + "'or TIMEIN = '" + TypeHereTextBox.Text +
"'or FIRSTNAME = '" + TypeHereTextBox.Text + "'or LASTNAME = '" + TypeHereTextBox.Text + "'or PHONENUMBER = '" + TypeHereTextBox.Text +
"'or EMAILID = '" + TypeHereTextBox.Text + "'or VEHICLENUMBER = '" + TypeHereTextBox.Text + "'or ADDRESSLINE1 = '" + TypeHereTextBox.Text +
"'or ADDRESSLINE2 = '" + TypeHereTextBox.Text + "'or CITY = '" + TypeHereTextBox.Text + "' or PINCODE = '" + TypeHereTextBox.Text +
"'or COMPANYNAME = '" + TypeHereTextBox.Text + "'or PURPOSE = '" + TypeHereTextBox.Text + "'or VISITORTYPE = '" + TypeHereTextBox.Text +
"'or TOMEET = '" + TypeHereTextBox.Text + "'or DEPARTMENT = '" + TypeHereTextBox.Text + "'or TIMEOUT = '" + TypeHereTextBox.Text +
"'or VISITORCOUNT = '" + TypeHereTextBox.Text + "'or REMARKS = '" + TypeHereTextBox.Text + "' or CARDNUMBER ='" + TypeHereTextBox.Text + "'", CON);
}
OADAP2 = new OracleDataAdapter(OLCMND4);
OADAP2.Fill(DTBLE2);
VisitorReportView.DataSource = DTBLE2;
}
con.close();
in the design what am i doing is.... i am using Autocomplete for every column in the table
(ie) passnumber,mobilenumber etc
but for date alone i am able to autocomplete the date in textbox if i select any one date it doesn't matches with the oracle date format
for matching both oracle and .net date format i am asking this
how to check or get the oracle date and convert it to above date format
sorry to ask this big qustn
Iftikar HussainPosted Aug 14, 2013, 6:58 AM
TO_Char(DATE,'DD-MON-YYYY') = '" + TypeHereTextBox.Text + "'", CON);
Regards,
Iftikar
kumartyrPosted Aug 14, 2013, 6:30 AM
i am searching and getting the data that are matching with the date [above format only]typed in textbox in the above said format in the datagridview
so i want the format to be like this but it may be past date or today date (ie) user may search for todaydate or any date in the past
so i cant understand this line in your coding
string currentDate = String.Format("{0:dd-MMM-yyyy}", DateTime.Now);
i think you are getting only todaydate and checking it with the textbox data but i want to search for any date in the past
Iftikar HussainPosted Aug 14, 2013, 6:09 AM
Try like this
Regards,
Iftikar