Wrox Programmer Forums
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 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
Old February 8th, 2007, 12:48 PM
Authorized User
Join Date: Dec 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to brawny4
Default Insert Issue into Acces DB

I am having a problem with the insert of the following code. I am getting the error:

"Data Type Mismatch in Criteria Expression"

I think the issue is with the Date but I don't know what I need to do to correct it.

        Dim Project As String = Guid.NewGuid.ToString.ToUpper()
        Dim Program_Name As String = "BRX999B"
        Dim Turnover_date As Date = Now()
        Dim objCommand As OleDbCommand = New OleDbCommand

        'intPosition = objCurrencyManager.Position

        objConnection = New OleDbConnection(strConnectionString)
        objCommand.Connection = objConnection
        objCommand.CommandText = "Insert into Projects" & _
        "(PDF_Number, Programs, Test_Plan, Turnover_date)" & _
        "Values(@PDF_Number, @Programs, @Test_Plan, @Turnover_date);"

        objCommand.Parameters.AddWithValue("@PDF_Number", Project)
        objCommand.Parameters.AddWithValue("@Programs", Program_Name)
        objCommand.Parameters.AddWithValue("@Test_Plan", "C:\Documents and Settings\e352532\My Documents\DB\Projects.mdb")
        objCommand.Parameters.AddWithValue("@Turnover_date ", Turnover_date)


Old February 11th, 2007, 04:10 PM
Authorized User
Join Date: Aug 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubisascends

Now() will return a full date string like 2/11/07 3:45 PM, make sure that your date/time field can handle this.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
Albert Einstein
US (German-born) physicist (1879 - 1955)
Old February 21st, 2007, 08:43 PM
Authorized User
Join Date: May 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to notrosh

do you have your date field set to a timestamp. you are trying to insert a variable that cannot be inserted into that field. basically you might be trying to insert a string into an integer field.

Similar Threads
Thread Thread Starter Forum Replies Last Post
image/db issue chaosengel PHP How-To 1 July 11th, 2007 02:22 PM
Insert Issue revisited cedwards Dreamweaver (all versions) 13 June 21st, 2005 03:02 PM
Insert issue? cedwards Dreamweaver (all versions) 14 June 17th, 2005 01:20 AM
Acces Db conversion angel_xpmx SQL Language 1 December 1st, 2004 12:08 PM
DB issue Hasee VS.NET 2002/2003 0 February 11th, 2004 07:57 AM

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