Solved

Quert question regarding date format.

Posted on 2004-10-18
17
542 Views
Last Modified: 2008-02-07
I have a problem with

case 2) for some reason it never pics up data between an interval.
Start 10-10-2004
End  13-10-2004


RC_DATA is of type VARCH2(19) in oracle

10-10-2004
11-10-2004
12-10-2004
13-10-2004

 



 public void btnRunQuery_Click(object sender, System.EventArgs e)
            {
                  string select_statement = "SELECT RC_PAYMNB, RC_CASHNB, RC_DATE, RC_DATA FROM TBRECEIPTS";
                  string DateString1 = ActiveDateTime3.Date.Day.ToString() + "-" + ActiveDateTime3.Date.Month.ToString() + "-" + ActiveDateTime3.Date.Year.ToString();
                  string DateString2 = ActiveDateTime4.Date.Day.ToString() + "-" + ActiveDateTime4.Date.Month.ToString() + "-" + ActiveDateTime4.Date.Year.ToString();

                  Response.Write (DateString1 +"<BR>");
                  Response.Write (DateString2 +"<BR>");
                  
                  switch (Group_RadioButtonList.SelectedIndex)
                  {
                        case 0:
                              select_statement += " Where RC_PAYMNB='" + txtPayment.Text + "'";
                              break;
                        case 1:
                              select_statement += " Where RC_CASHNB='" + txtCashier.Text + "'";
                              break;
                        case 2:
                              select_statement += " Where RC_DATE <='" + ActiveDateTime4.Date + "' And RC_DATE >= '" + ActiveDateTime3.Date + "'"; //i don't know the type of these fields so this is the reason that i use text property
                              break;
                  }


                  OdbcConnection myConnection =  new
                  OdbcConnection("DSN=POS;UID=system;PWD=system");

                  // Populate the ddlDataSet1
                  myConnection.Open();
                  string strSQLDDL = select_statement;
                  OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,myConnection);
                  ddlDataSet1.Clear();  
                  myDataAdapter.Fill(ddlDataSet1);
                  myDataAdapter.Dispose();
                  myDataAdapter = null;
                  myConnection.Close();
                  ReceiptsDataGrid.DataSource = ddlDataSet1.Tables[0];
                  ReceiptsDataGrid.DataBind();
            
        }

So how I am not comparing the date values appropriately.

0
Comment
Question by:mathieu_cupryk
  • 9
  • 8
17 Comments
 
LVL 28

Expert Comment

by:mmarinov
Comment Utility
Hi mathieu_cupryk,

it is like this because you don't compare dates but strings
i'm not familiar with oracle database but there should be a function that convert string to date ( in sql server it is CAST(string_value as datetime)
if you can find such covert function you can type:

" Where CAST(RC_DATE as datetime) <='" + ActiveDateTime4.Date + "'  And CAST(RC_DATE as datetime) >= '" + ActiveDateTime3.Date + "'"

B..M
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
Tried it and it does not work. Looking.
0
 
LVL 28

Expert Comment

by:mmarinov
Comment Utility
mathieu_cupryk,
what was the result? have you received any errors ?
B..M
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
case 2:
                              select_statement += " Where RC_DATE <='" + ActiveDateTime4.Date + "' And RC_DATE >= '" + ActiveDateTime3.Date + "'"; //i don't know the type of these fields so this is the reason that i use text property
                              break;
                  }

We need to implement something

SELECT TO_CHAR(RC_DATE, 'DD-MM-YYYY') AS RC_DATE

0
 
LVL 28

Expert Comment

by:mmarinov
Comment Utility
mathieu_cupryk,

try this

select_statement += " Where To_Date(RC_DATE, 'MMDDYY') <=To_Date('" + ActiveDateTime4.Date + "', 'MMDDYY') And To_Date(RC_DATE, 'MMDDYY') >= To_Date('" + ActiveDateTime3.Date + "', 'MMDDYY')"; //i don't know the type of these fields so this is the reason that i use text property

B..M
0
 
LVL 28

Assisted Solution

by:mmarinov
mmarinov earned 500 total points
Comment Utility
mathieu_cupryk,

you can also try like in this sample:
SELECT * from odbytcdod_lis WHERE datecreated BETWEEN to_date('29.06.2002','dd.mm.yyyy') and to_date('30.06.2002','dd.mm.yyyy')

B..M
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
Server Error in '/MSPOS' Application.
--------------------------------------------------------------------------------

ERROR [HY000] [Oracle][ODBC][Ora]ORA-01847: day of month must be between 1 and last day of month
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.Data.Odbc.OdbcException: ERROR [HY000] [Oracle][ODBC][Ora]ORA-01847: day of month must be between 1 and last day of month

Source Error:


Line 243:                  OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,myConnection);
Line 244:                  ddlDataSet1.Clear();  
Line 245:                  myDataAdapter.Fill(ddlDataSet1);
Line 246:                  myDataAdapter.Dispose();
Line 247:                  myDataAdapter = null;
 

Source File: c:\inetpub\wwwroot\mspos\receipts.aspx.cs    Line: 245

Stack Trace:


[OdbcException: ERROR [HY000] [Oracle][ODBC][Ora]ORA-01847: day of month must be between 1 and last day of month
]
   Microsoft.Data.Odbc.OdbcConnection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode) +27
   Microsoft.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method) +838
   Microsoft.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior) +53
   Microsoft.Data.Odbc.OdbcCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +5
   System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
   MSPOS.Receipts.btnRunQuery_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\mspos\receipts.aspx.cs:245
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1281

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
Request Details
Session Id: 0uof0zzfh1a5or31og3nfx45 Request Type: POST
Time of Request: 10/18/2004 5:01:04 PM Status Code: 500
Request Encoding: Unicode (UTF-8) Response Encoding: Unicode (UTF-8)
Trace Information
Category Message From First(s) From Last(s)
aspx.page Begin Init  
aspx.page End Init 0.000066 0.000066
aspx.page Begin LoadViewState 0.000099 0.000033
aspx.page End LoadViewState 0.000477 0.000379
aspx.page Begin ProcessPostData 0.000519 0.000042
aspx.page End ProcessPostData 0.000655 0.000136
aspx.page Begin ProcessPostData Second Try 0.000687 0.000032
aspx.page End ProcessPostData Second Try 0.000718 0.000030
aspx.page Begin Raise ChangedEvents 0.000743 0.000025
aspx.page End Raise ChangedEvents 0.001091 0.000348
aspx.page Begin Raise PostBackEvent 0.001130 0.000039
Unhandled Execution Error
ERROR [HY000] [Oracle][ODBC][Ora]ORA-01847: day of month must be between 1 and last day of month

  at Microsoft.Data.Odbc.OdbcConnection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode)
  at Microsoft.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method)
  at Microsoft.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
  at Microsoft.Data.Odbc.OdbcCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
  at MSPOS.Receipts.btnRunQuery_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\mspos\receipts.aspx.cs:line 245
  at System.EventHandler.Invoke(Object sender, EventArgs e)
  at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
  at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  at System.Web.UI.Page.ProcessRequestMain() 0.219558 0.218428
Control Tree
Control Id Type Render Size Bytes (including children) Viewstate Size Bytes (excluding children)
Cookies Collection
Name Value Size
Polls_Question20 101 20
ASP.NET_SessionId 0uof0zzfh1a5or31og3nfx45 42
Headers Collection
Name Value
Cache-Control no-cache
Connection Keep-Alive
Content-Length 678
Content-Type application/x-www-form-urlencoded
Accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Encoding gzip, deflate
Accept-Language en-us
Cookie Polls_Question20=101; ASP.NET_SessionId=0uof0zzfh1a5or31og3nfx45
Host localhost
Referer http://localhost/MSPOS/Receipts.aspx
User-Agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)
Form Collection
Name Value
__VIEWSTATE dDwyMDc2ODMyNjU7dDw7bDxpPDE+Oz47bDx0PDtsPGk8OT47aTwxMT47aTwxNT47PjtsPHQ8cDxsPF9kYXRlOz47bDxTeXN0ZW0uRGF0ZVRpbWUsIG1zY29ybGliLCBWZXJzaW9uPTEuMC41MDAwLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OTwyMDA0LTEwLTE4Pjs+Pjs7Pjt0PHA8bDxfZGF0ZTs+O2w8NTA8MjAwNC0xMC0xOD47Pj47Oz47dDxAMDw7Ozs7Ozs7Ozs7Pjs7Pjs+Pjs+Pjs+A0wf5fFbyL3ACXkWpdrRJpO0uHE=
Group_RadioButtonList StartDate
txtPayment  
txtCashier  
ActiveDateTime3 632336544000000000
ActiveDateTime3_day 10
ActiveDateTime3_month 10
ActiveDateTime3_year 2004
ActiveDateTime4 632336544000000000
ActiveDateTime4_day 11
ActiveDateTime4_month 10
ActiveDateTime4_year 2004
btnRunQuery Run Query
Server Variables
Name Value
ALL_HTTP HTTP_CACHE_CONTROL:no-cache HTTP_CONNECTION:Keep-Alive HTTP_CONTENT_LENGTH:678 HTTP_CONTENT_TYPE:application/x-www-form-urlencoded HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:en-us HTTP_COOKIE:Polls_Question20=101; ASP.NET_SessionId=0uof0zzfh1a5or31og3nfx45 HTTP_HOST:localhost HTTP_REFERER:http://localhost/MSPOS/Receipts.aspx HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)  
ALL_RAW Cache-Control: no-cache Connection: Keep-Alive Content-Length: 678 Content-Type: application/x-www-form-urlencoded Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */* Accept-Encoding: gzip, deflate Accept-Language: en-us Cookie: Polls_Question20=101; ASP.NET_SessionId=0uof0zzfh1a5or31og3nfx45 Host: localhost Referer: http://localhost/MSPOS/Receipts.aspx User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)  
APPL_MD_PATH /LM/W3SVC/1/Root/MSPOS
APPL_PHYSICAL_PATH C:\Inetpub\wwwroot\MSPOS\
AUTH_TYPE  
AUTH_USER  
AUTH_PASSWORD  
LOGON_USER  
REMOTE_USER  
CERT_COOKIE  
CERT_FLAGS  
CERT_ISSUER  
CERT_KEYSIZE  
CERT_SECRETKEYSIZE  
CERT_SERIALNUMBER  
CERT_SERVER_ISSUER  
CERT_SERVER_SUBJECT  
CERT_SUBJECT  
CONTENT_LENGTH 678
CONTENT_TYPE application/x-www-form-urlencoded
GATEWAY_INTERFACE CGI/1.1
HTTPS off
HTTPS_KEYSIZE  
HTTPS_SECRETKEYSIZE  
HTTPS_SERVER_ISSUER  
HTTPS_SERVER_SUBJECT  
INSTANCE_ID 1
INSTANCE_META_PATH /LM/W3SVC/1
LOCAL_ADDR 127.0.0.1
PATH_INFO /MSPOS/Receipts.aspx
PATH_TRANSLATED C:\Inetpub\wwwroot\MSPOS\Receipts.aspx
QUERY_STRING  
REMOTE_ADDR 127.0.0.1
REMOTE_HOST 127.0.0.1
REMOTE_PORT 4900
REQUEST_METHOD POST
SCRIPT_NAME /MSPOS/Receipts.aspx
SERVER_NAME localhost
SERVER_PORT 80
SERVER_PORT_SECURE 0
SERVER_PROTOCOL HTTP/1.1
SERVER_SOFTWARE Microsoft-IIS/6.0
URL /MSPOS/Receipts.aspx
HTTP_CACHE_CONTROL no-cache
HTTP_CONNECTION Keep-Alive
HTTP_CONTENT_LENGTH 678
HTTP_CONTENT_TYPE application/x-www-form-urlencoded
HTTP_ACCEPT image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_ACCEPT_LANGUAGE en-us
HTTP_COOKIE Polls_Question20=101; ASP.NET_SessionId=0uof0zzfh1a5or31og3nfx45
HTTP_HOST localhost
HTTP_REFERER http://localhost/MSPOS/Receipts.aspx
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 500 total points
Comment Utility
mathieu_cupryk,

may be you type an incorrect date format, can you post the format, and date strings that you passed to the statement

B..M
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:mathieu_cupryk
Comment Utility

            public void btnRunQuery_Click(object sender, System.EventArgs e)
            {
                  string select_statement = "SELECT RC_PAYMNB, RC_CASHNB, RC_DATE, RC_DATA FROM TBRECEIPTS";
                  string DateString1 = ActiveDateTime3.Date.Day.ToString() + "-" + ActiveDateTime3.Date.Month.ToString() + "-" + ActiveDateTime3.Date.Year.ToString();
                  string DateString2 = ActiveDateTime4.Date.Day.ToString() + "-" + ActiveDateTime4.Date.Month.ToString() + "-" + ActiveDateTime4.Date.Year.ToString();

                  Response.Write (DateString1 +"<BR>");
                  Response.Write (DateString2 +"<BR>");
                  
                  switch (Group_RadioButtonList.SelectedIndex)
                  {
                        case 0:
                              select_statement += " Where RC_PAYMNB='" + txtPayment.Text + "'";
                              break;
                        case 1:
                              select_statement += " Where RC_CASHNB='" + txtCashier.Text + "'";
                              break;
                        case 2:
                              select_statement += " Where To_Date(RC_DATE, 'MMDDYY') <=To_Date('" + ActiveDateTime4.Date + "', 'MMDDYY') And To_Date(RC_DATE, 'MMDDYY') >= To_Date('" + ActiveDateTime3.Date + "', 'MMDDYY')";
 
//                              select_statement += " Where RC_DATE <='" + ActiveDateTime4.Date + "' And RC_DATE >= '" + ActiveDateTime3.Date + "'"; //i don't know the type of these fields so this is the reason that i use text property
                              break;
                  }

                  //SELECT TO_CHAR(RC_DATE, 'DD-MM-YYYY') AS RC_DATE


                  OdbcConnection myConnection =  new
                  OdbcConnection("DSN=POS;UID=system;PWD=system");

                  // Populate the ddlDataSet1
                  myConnection.Open();
                  string strSQLDDL = select_statement;
                  OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,myConnection);
                  ddlDataSet1.Clear();  
                  myDataAdapter.Fill(ddlDataSet1);
                  myDataAdapter.Dispose();
                  myDataAdapter = null;
                  myConnection.Close();
                  ReceiptsDataGrid.DataSource = ddlDataSet1.Tables[0];
                  ReceiptsDataGrid.DataBind();
            
        }
0
 
LVL 28

Expert Comment

by:mmarinov
Comment Utility
yes, it is wrong, because you pass incorrect values to the statement

try this

select_statement += " Where To_Date(RC_DATE, 'DDMMYY') <=To_Date('" + DateString1  + "', 'DDMMYY') And To_Date(RC_DATE, 'DDMMYY') >= To_Date('" + DateString2  + "', 'DDMMYY')";

HTH
B..M
 
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
Server Error in '/MSPOS' Application.
--------------------------------------------------------------------------------

ERROR [HY000] [Oracle][ODBC][Ora]ORA-01843: not a valid month
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.Data.Odbc.OdbcException: ERROR [HY000] [Oracle][ODBC][Ora]ORA-01843: not a valid month

Source Error:


Line 240:                  OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,myConnection);
Line 241:                  ddlDataSet1.Clear();  
Line 242:                  myDataAdapter.Fill(ddlDataSet1);
Line 243:                  myDataAdapter.Dispose();
Line 244:                  myDataAdapter = null;
 

Source File: c:\inetpub\wwwroot\mspos\receipts.aspx.cs    Line: 242

Stack Trace:


[OdbcException: ERROR [HY000] [Oracle][ODBC][Ora]ORA-01843: not a valid month
]
   Microsoft.Data.Odbc.OdbcConnection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode) +27
   Microsoft.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method) +838
   Microsoft.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior) +53
   Microsoft.Data.Odbc.OdbcCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +5
   System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
   MSPOS.Receipts.btnRunQuery_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\mspos\receipts.aspx.cs:242
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1281

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
Request Details
Session Id: c5fe15yo5quqzorbepxgyazt Request Type: POST
Time of Request: 10/19/2004 10:15:57 AM Status Code: 500
Request Encoding: Unicode (UTF-8) Response Encoding: Unicode (UTF-8)
Trace Information
Category Message From First(s) From Last(s)
aspx.page Begin Init  
aspx.page End Init 0.000061 0.000061
aspx.page Begin LoadViewState 0.000095 0.000034
aspx.page End LoadViewState 0.011327 0.011232
aspx.page Begin ProcessPostData 0.011408 0.000081
aspx.page End ProcessPostData 0.019053 0.007645
aspx.page Begin ProcessPostData Second Try 0.019130 0.000077
aspx.page End ProcessPostData Second Try 0.019166 0.000035
aspx.page Begin Raise ChangedEvents 0.019189 0.000024
aspx.page End Raise ChangedEvents 0.020719 0.001529
aspx.page Begin Raise PostBackEvent 0.020781 0.000063
Unhandled Execution Error
ERROR [HY000] [Oracle][ODBC][Ora]ORA-01843: not a valid month

  at Microsoft.Data.Odbc.OdbcConnection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode)
  at Microsoft.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method)
  at Microsoft.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
  at Microsoft.Data.Odbc.OdbcCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
  at MSPOS.Receipts.btnRunQuery_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\mspos\receipts.aspx.cs:line 242
  at System.EventHandler.Invoke(Object sender, EventArgs e)
  at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
  at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  at System.Web.UI.Page.ProcessRequestMain() 2.067011 2.046230
Control Tree
Control Id Type Render Size Bytes (including children) Viewstate Size Bytes (excluding children)
Cookies Collection
Name Value Size
Polls_Question20 101 20
ASP.NET_SessionId c5fe15yo5quqzorbepxgyazt 42
Headers Collection
Name Value
Cache-Control no-cache
Connection Keep-Alive
Content-Length 678
Content-Type application/x-www-form-urlencoded
Accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Encoding gzip, deflate
Accept-Language en-us
Cookie Polls_Question20=101; ASP.NET_SessionId=c5fe15yo5quqzorbepxgyazt
Host localhost
Referer http://localhost/MSPOS/Receipts.aspx
User-Agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)
Form Collection
Name Value
__VIEWSTATE dDwyMDc2ODMyNjU7dDw7bDxpPDE+Oz47bDx0PDtsPGk8OT47aTwxMT47aTwxNT47PjtsPHQ8cDxsPF9kYXRlOz47bDxTeXN0ZW0uRGF0ZVRpbWUsIG1zY29ybGliLCBWZXJzaW9uPTEuMC41MDAwLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OTwyMDA0LTEwLTE5Pjs+Pjs7Pjt0PHA8bDxfZGF0ZTs+O2w8NTA8MjAwNC0xMC0xOT47Pj47Oz47dDxAMDw7Ozs7Ozs7Ozs7Pjs7Pjs+Pjs+Pjs+XspLqC08TG9eDdabrOOB2cJk9p0=
Group_RadioButtonList StartDate
txtPayment  
txtCashier  
ActiveDateTime3 632337408000000000
ActiveDateTime3_day 10
ActiveDateTime3_month 10
ActiveDateTime3_year 2004
ActiveDateTime4 632337408000000000
ActiveDateTime4_day 13
ActiveDateTime4_month 10
ActiveDateTime4_year 2004
btnRunQuery Run Query
Server Variables
Name Value
ALL_HTTP HTTP_CACHE_CONTROL:no-cache HTTP_CONNECTION:Keep-Alive HTTP_CONTENT_LENGTH:678 HTTP_CONTENT_TYPE:application/x-www-form-urlencoded HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:en-us HTTP_COOKIE:Polls_Question20=101; ASP.NET_SessionId=c5fe15yo5quqzorbepxgyazt HTTP_HOST:localhost HTTP_REFERER:http://localhost/MSPOS/Receipts.aspx HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)  
ALL_RAW Cache-Control: no-cache Connection: Keep-Alive Content-Length: 678 Content-Type: application/x-www-form-urlencoded Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */* Accept-Encoding: gzip, deflate Accept-Language: en-us Cookie: Polls_Question20=101; ASP.NET_SessionId=c5fe15yo5quqzorbepxgyazt Host: localhost Referer: http://localhost/MSPOS/Receipts.aspx User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)  
APPL_MD_PATH /LM/W3SVC/1/Root/MSPOS
APPL_PHYSICAL_PATH C:\Inetpub\wwwroot\MSPOS\
AUTH_TYPE  
AUTH_USER  
AUTH_PASSWORD  
LOGON_USER  
REMOTE_USER  
CERT_COOKIE  
CERT_FLAGS  
CERT_ISSUER  
CERT_KEYSIZE  
CERT_SECRETKEYSIZE  
CERT_SERIALNUMBER  
CERT_SERVER_ISSUER  
CERT_SERVER_SUBJECT  
CERT_SUBJECT  
CONTENT_LENGTH 678
CONTENT_TYPE application/x-www-form-urlencoded
GATEWAY_INTERFACE CGI/1.1
HTTPS off
HTTPS_KEYSIZE  
HTTPS_SECRETKEYSIZE  
HTTPS_SERVER_ISSUER  
HTTPS_SERVER_SUBJECT  
INSTANCE_ID 1
INSTANCE_META_PATH /LM/W3SVC/1
LOCAL_ADDR 127.0.0.1
PATH_INFO /MSPOS/Receipts.aspx
PATH_TRANSLATED C:\Inetpub\wwwroot\MSPOS\Receipts.aspx
QUERY_STRING  
REMOTE_ADDR 127.0.0.1
REMOTE_HOST 127.0.0.1
REMOTE_PORT 3097
REQUEST_METHOD POST
SCRIPT_NAME /MSPOS/Receipts.aspx
SERVER_NAME localhost
SERVER_PORT 80
SERVER_PORT_SECURE 0
SERVER_PROTOCOL HTTP/1.1
SERVER_SOFTWARE Microsoft-IIS/6.0
URL /MSPOS/Receipts.aspx
HTTP_CACHE_CONTROL no-cache
HTTP_CONNECTION Keep-Alive
HTTP_CONTENT_LENGTH 678
HTTP_CONTENT_TYPE application/x-www-form-urlencoded
HTTP_ACCEPT image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_ACCEPT_LANGUAGE en-us
HTTP_COOKIE Polls_Question20=101; ASP.NET_SessionId=c5fe15yo5quqzorbepxgyazt
HTTP_HOST localhost
HTTP_REFERER http://localhost/MSPOS/Receipts.aspx
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)
0
 
LVL 28

Expert Comment

by:mmarinov
Comment Utility
please, check your data that you pass to the statement

B..M
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
'DDMMYY'

This should be 'DD-MM-YYYYY'?
0
 
LVL 28

Expert Comment

by:mmarinov
Comment Utility
this is the format - not the values
check the content of DateString1  and DateString2

B..M
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
string select_statement = "SELECT RC_PAYMNB, RC_CASHNB, RC_DATE, RC_DATA FROM TBRECEIPTS";
                  string DateString1 = ActiveDateTime3.Date.Day.ToString() + ActiveDateTime3.Date.Month.ToString() + ActiveDateTime3.Date.Year.ToString();
                  string DateString2 = ActiveDateTime4.Date.Day.ToString() + ActiveDateTime4.Date.Month.ToString() + ActiveDateTime4.Date.Year.ToString();

                  Response.Write (DateString1 +"<BR>");
                  Response.Write (DateString2 +"<BR>");
                  
                  switch (Group_RadioButtonList.SelectedIndex)
                  {
                        case 0:
                              select_statement += " Where RC_PAYMNB='" + txtPayment.Text + "'";
                              break;
                        case 1:
                              select_statement += " Where RC_CASHNB='" + txtCashier.Text + "'";
                              break;
                        case 2:
                              select_statement += " Where To_Date(RC_DATE, 'DDMMYY') <= To_Date('" + DateString1  + "', 'DDMMYY') And To_Date(RC_DATE, 'DDMMYY') >= To_Date('" + DateString2  + "', 'DDMMYY')";
                              break;
                  }


Ok but know I have to pu DDMMYYYYY
and it does not like it?
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
I GET this

"SELECT RC_PAYMNB, RC_CASHNB, RC_DATE, RC_DATA FROM TBRECEIPTS Where To_Date(RC_DATE, 'DDMMYY') <=To_Date('9102004', 'DDMMYY') And To_Date(RC_DATE, 'DDMMYY') >= To_Date('13102004', 'DDMMYY')"
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
Ok I need help on this statement I am stuck?


public void btnRunQuery_Click(object sender, System.EventArgs e)
            {
                  string select_statement = "SELECT RC_PAYMNB, RC_CASHNB, RC_DATE, RC_DATA FROM TBRECEIPTS";
                  string DateString1 = ActiveDateTime3.Date.Day.ToString() + ActiveDateTime3.Date.Month.ToString() +  ActiveDateTime3.Date.Year.ToString();
                  string DateString2 = ActiveDateTime4.Date.Day.ToString() +  ActiveDateTime4.Date.Month.ToString() + ActiveDateTime4.Date.Year.ToString();

                  Response.Write (DateString1 +"<BR>");
                  Response.Write (DateString2 +"<BR>");
                  
                  switch (Group_RadioButtonList.SelectedIndex)
                  {
                        case 0:
                              select_statement += " Where RC_PAYMNB='" + txtPayment.Text + "'";
                              break;
                        case 1:
                              select_statement += " Where RC_CASHNB='" + txtCashier.Text + "'";
                              break;
                        case 2:
                              select_statement += " Where To_Date(RC_DATE, 'DDMMYYYY') <=To_Date('" + DateString2.ToString("DDMMYYYY") + "', 'DDMMYYYY') And To_Date(RC_DATE, 'DDMMYYYY') >= To_Date('" + DateString1.ToString("DDMMYYYY") + "', 'DDMMYYYY')";
                              Response.Write (select_statement);
                              break;
                  }

            

                  OdbcConnection myConnection =  new
                  OdbcConnection("DSN=POS;UID=system;PWD=system");

                  // Populate the ddlDataSet1
                  myConnection.Open();
                  string strSQLDDL = select_statement;
                  OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,myConnection);
                  ddlDataSet1.Clear();  
                  myDataAdapter.Fill(ddlDataSet1);
                  myDataAdapter.Dispose();
                  myDataAdapter = null;
                  myConnection.Close();
                  ReceiptsDataGrid.DataSource = ddlDataSet1.Tables[0];
                  ReceiptsDataGrid.DataBind();
            
        }
c:\inetpub\wwwroot\mspos\receipts.aspx.cs(232,78): error CS1502: The best overloaded method match for 'string.ToString(System.IFormatProvider)' has some invalid arguments

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now