Wrox Programmer Forums
|
BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 Databases by Thearon Willis; ISBN: 9780764588945
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 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 July 31st, 2006, 08:55 AM
Authorized User
 
Join Date: Aug 2005
Posts: 88
Thanks: 4
Thanked 0 Times in 0 Posts
Default DataType Mismatch Errorror

I am working on an application with 28 fields in the datebase and following the examples from "Beginning Visual Basic 2005 Databases".

After spending several days i finally tracked down the fields that are giving me a problem, they are the DateTime datatype.

The query I am using contains this SQL statement.
[u]usp_InsertEmployee</u>
INSERT INTO tStaff (StartDate, BirthDate, Statusdate )
VALUES (@StartDate, @BirthDate, @Statusdate);

The dates are entered into DateTime Picker controls and then converted to date data types with the following code:

        'Convert date text boxes to DateTime variables...
        dtBirthDate = Convert.ToDateTime(dtpBirthDate.Value)
        dtStartDate = Convert.ToDateTime(dtpStartDate.Value)
        dtStatusDate = Convert.ToDateTime(dtpStatusDate.Value)

I then set the parameter values with this code:

Using objdata As New WDABase
   Try
     objdata.SQL = "usp_InsertEmployee"
     objdata.InitializeCommand()
     objdata.OpenConnection()
     objdata.AddParameter("BirthDate", OleDb.OleDbType.Date,
         8,dtBirthDate)
     objdata.AddParameter("StatusDate", OleDb.OleDbType.Date,
         8, dtBirthDate)
     objdata.AddParameter("StartDate", OleDb.OleDbType.Date,
         8,dtStartDate)
     intRowsAffected = objdata.Command.ExecuteNonQuery

     Catch ex As Exception
          MessageBox.Show(ex.Message)
   End Try
 objdata.CloseConnection()
 End Using

The three variables(dtBirthDate, dtStatusDate and dtStartDate) are declared as DateTime data types.

I am at a frustrated and at a complete loss as to why I keep getting the error, can someone please help.


 
Old July 31st, 2006, 07:17 PM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Is your database Access or SQL Server?

Thearon
 
Old August 1st, 2006, 06:48 AM
Authorized User
 
Join Date: Aug 2005
Posts: 88
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Access 2000

 
Old August 3rd, 2006, 09:27 AM
Authorized User
 
Join Date: Aug 2005
Posts: 88
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Thearon:

I think that I have found my problem.

Ientered one field at a time in both my Access SQL query and in the VB code to insert the data.

Everything worked fine for the first 15 fields. When I added the 16th field I got the error. I then changed the fields by removing one that worked fine pevioudly and it worked. Whenever I attempted to add the 16th field I got the error.

Does the Express edition have a limit in the number of fields that I can "Inser Into"?

I hope that I explained this Ok.

 
Old August 4th, 2006, 09:05 AM
Authorized User
 
Join Date: Aug 2005
Posts: 88
Thanks: 4
Thanked 0 Times in 0 Posts
Default

I found my problem and there is no limit of 15. With all the fields in the table I had some problems in making sure that the "Insert Into", "Values" and parameters in VB were the same.

Thanks for trying to help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
(0x800A000D) datatype mismatch peonysmiles ASP.NET 1.0 and 1.1 Basics 1 August 26th, 2008 08:13 AM
datatype umeshtheone SQL Server 2000 2 May 16th, 2007 11:56 AM
DataType Mismatch webgen ASP.NET 1.0 and 1.1 Professional 3 November 17th, 2005 12:35 PM
Datatype mismatch on datetime column??? reidcor SQL Server DTS 3 May 9th, 2005 02:13 PM
datatype ngang SQL Language 1 November 18th, 2003 09:55 AM





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