Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.