Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases 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:44 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 VB Databases

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.

Code:
        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)
        objConnection.Open()
        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)


mfb
__________________
mfb
 
Old March 14th, 2007, 08:41 AM
Authorized User
 
Join Date: Jun 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You need to set the object command type to say if it is either a stored proc or a text command that is going to be run to start with. If your going to use a stored proc, then the commandtext needs to reference the stored proc name. If your not using a stored proc and set the commandtext as you have it, then you do not need to declare the parameters as they serve no value. In you commandText as you currently have it, you have not declared the Values part correctly.

"Values(" & Project & ",'" & Program_name & "',.......






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use access 2007 databases in vb 2005? Richard C. McAdams BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 June 16th, 2008 11:48 AM
VB, Access and ACT Databases dbrook007 Pro VB Databases 0 July 6th, 2007 05:32 AM
vb and databases , is it possible.... Blue Eyes Visual Basic 2005 Basics 3 July 19th, 2006 05:04 PM
VB databases and Reports samnikh VB Databases Basics 1 July 4th, 2005 12:32 AM
UpDATE IN VB FROM TWO DATABASES akash VB How-To 5 April 20th, 2005 03:44 AM





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