473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

data type mismatch between vb date datatype and ms access datetime data type

19
I'v designed a ms access database table with one field having Datetime datatype. I can Insert data into it from vb.net front end by using
Expand|Select|Wrap|Line Numbers
  1. trns_dt = DateTime.Now.Date
  2.  
.
But when I fetch records from the tableand assign the dataset datasource as da, it shows datatype mismatch error.
Expand|Select|Wrap|Line Numbers
  1.  
  2. da = New OleDbDataAdapter("Select * from Daily_Transaction where trans_date between '" & dtp_from_dt.value & "' and '" & dtp_To.value & "' ", con)
  3. ds = New DataSet
  4.                 ds.Clear()
  5.                 da.Fill(ds, "Daily_Transaction")
  6.                 DGV_Admin.DataSource = ds.Tables(0)
  7.                 DGV_Admin.Show()
  8.  
Plz help ASAP
Dec 27 '10 #1

✓ answered by Stewart Ross

Hi. In line 2 you are treating the dates as text by enclosing them in quotes, which I think is the source of your type mismatch. The Access query engine uses the pound sign (#) as a delimiter for dates, so line 2 should be rewritten as:

Expand|Select|Wrap|Line Numbers
  1. da = New OleDbDataAdapter("Select * from Daily_Transaction where trans_date between #" & dtp_from_dt.value & "# and #" & dtp_To.value & "# ", con)
Please note that for comparisons such as BETWEEN to work consistently date values presented as literals need to be in ANSI standard format - that is, month-first as mm/dd/yyyy.

-Stewart

2 5527
Stewart Ross
2,545 Expert Mod 2GB
Hi. In line 2 you are treating the dates as text by enclosing them in quotes, which I think is the source of your type mismatch. The Access query engine uses the pound sign (#) as a delimiter for dates, so line 2 should be rewritten as:

Expand|Select|Wrap|Line Numbers
  1. da = New OleDbDataAdapter("Select * from Daily_Transaction where trans_date between #" & dtp_from_dt.value & "# and #" & dtp_To.value & "# ", con)
Please note that for comparisons such as BETWEEN to work consistently date values presented as literals need to be in ANSI standard format - that is, month-first as mm/dd/yyyy.

-Stewart
Dec 27 '10 #2
GR M
19
Thanks A lot sir.
Dec 28 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Sean | last post by:
I'm new to using long raw fields with ASP. I know it would be easier to leave the files on the file system, but the client wants them in the database. Based on what I've read so far, I have used...
0
by: James | last post by:
I am using an sqldatareader and trying to add items from a sql select statement to a listview control. All columns from sql select statement are added into listview except one column that is a sql...
4
by: leslie_tighe | last post by:
Hello, I have a method on a com+ object that is returning an array of objects. I know the array is popluated as calls to check the ubound and lbound show valid values. However, any calls to...
2
by: David Slinn | last post by:
I have created a simple XML document, generated a schema from it (which Visual Studio makes everything a string element). I then went through and changed all fields that are dates to the Date data...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
1
by: jodyblau | last post by:
I have a database which works fine until I create and MDE file. Once I create the MDE, when I open a particular form I get a "Type Mismatch" error. Because its an MDE file, I can't step through...
0
by: MaartenVR | last post by:
sub: MS SQL server and (missing) ANSI DATE-datatype I’m working at a company who has developed a large client/server application in Delphi 6, with Interbase as the DB-server (both Borland...
3
by: Bruce Lawrence | last post by:
I've got a form that when it opens it prompts the user for 2 peices of information. The Asset and the Date. getasset = InputBox("Enter the Asset Number") If getasset = "" Then Exit Sub Else...
9
by: nixonmg | last post by:
When the Command Button "Notify" is clicked, I am wanting to send out an email to the user with appropriate information in the email (works great), check the "Notified" check box (does not work), and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.