Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 24th, 2004, 05:50 AM
Authorized User
 
Join Date: Dec 2004
Location: mumbai, maharastra, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to akhilvira
Default Problem retriving data from access

hi
       I am using C# as the language for programming .I am accessing table in the access database . The table has three fields EmpName(text), FromDate(DateTime) and ToDate(DateTime). I am getting error while executing reader .

The Query string is
SELECT * FROM EmpLeaveApproved WHERE EmpName LIKE 'Akhil Vira' AND FromDate BETWEEN '1/1/1999' AND '1/1/2000';

The error message that i am getting is
Data type mismatch in criteria expression.

Can anybody please point out were i am making mistake
Thanks in advance

Regards
Akhil Vira
  #2 (permalink)  
Old December 24th, 2004, 06:15 AM
Authorized User
 
Join Date: Dec 2004
Location: mumbai, maharastra, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to akhilvira
Default

I will add the code that is getting caught .




strQuery = "SELECT * FROM EmpLeaveApproved WHERE EmpName LIKE '"+strEmpName+"' AND FromDate BETWEEN '"+date.ToShortDateString()+"' AND '"+ date.AddYears(1).ToShortDateString()+"';";
                OleDbConnection conn= null;
                OleDbDataReader reader = null;

                conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; "+
                        "Data Source=" + Server.MapPath("Data/leaverecord.mdb"));
                conn.Open();
                OleDbCommand cmd = new OleDbCommand(strQuery,conn);
                reader = cmd.ExecuteReader();



it is caught in catch when it executes cm.ExecuteReader.
  #3 (permalink)  
Old December 24th, 2004, 06:48 AM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I suppose the problem is with query string....

SELECT * FROM EmpLeaveApproved WHERE EmpName LIKE 'Akhil Vira' AND FromDate BETWEEN #1/1/1999# AND #1/1/2000#

this query works well and good
just try with this sysntax...just replace ur "'" with "#"...
hope this will do
regds
rahman

  #4 (permalink)  
Old December 24th, 2004, 07:03 AM
Authorized User
 
Join Date: Dec 2004
Location: mumbai, maharastra, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to akhilvira
Default

thanks rehman_reck it worked .
U were really helpful
Thank u very much

Regards
Akhil Vira


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data access problem middletree BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 May 22nd, 2008 03:13 PM
Data Access Pages Problem Help! jdbash1 Access ASP 1 November 26th, 2006 06:32 PM
retriving data from master tables ali_md SQL Server 2000 0 January 31st, 2006 07:23 AM
Problem with Data Access eberly BOOK: Professional C#, 2nd and 3rd Editions 0 April 2nd, 2005 09:36 PM
Data access page access problem :) kev_79 Access 0 September 4th, 2003 04:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.