Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
|
BOOK: Beginning VB.NET Databases
This is the forum to discuss the Wrox book Beginning VB.NET Databases by Thearon Willis; ISBN: 9780764568008
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET Databases 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 September 2nd, 2007, 06:16 AM
Authorized User
 
Join Date: Jan 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Insert Query not workng because of Replication?

Hi guys,

I wonder if you could help?

I've just replicated my database into master and replica databases. Now I'm retesting my vb.net application (it uses some of the framework of Beginning VB.NET Databases).

I'm running some code that uses an 'insert' query and now I get the following error message:

Number of query values and destination fields are not the same

Here's the query code:

objData.SQL = "INSERT INTO [FitnessTestHistory] " & _
   "VALUES(@ID, @DATEOFTEST, @VESSELID)"

objData.InitializeCommand()

objData.AddParameter("@ID", OleDb.OleDbType.Guid, 16, guidCrewMemberID)
objData.AddParameter("@DATEOFTEST", OleDb.OleDbType.DBDate, 8, DateTime.Parse(txtDateOfTest.Text))
objData.AddParameter("@VESSELID", OleDb.OleDbType.VarChar, 5, txtVessel.Text)

objData.OpenConnection()

intRowsAffected = objData.Command.ExecuteNonQuery()


MS Access automatically added the following fields to each table when I did the reputation:

s_ColLineage
s_Generation
s_GUID
s_Lineage

Are these the problem? Can anyone tell me what is going on? Thanks in advance.

 
Old September 3rd, 2007, 05:45 AM
Authorized User
 
Join Date: Jan 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I've managed to sort out a work around answer folks.

Instead of hard coding the "INSERT INTO [tablename] part of the SQL statement, in my Access table, I created parameter query and then called the parameter query from the SQL object.

This seems to work.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Into Query. rupen Access VBA 5 July 30th, 2007 09:58 AM
Where does insert query go? bph Access VBA 5 June 12th, 2007 12:26 PM
INSERT Query Neal SQL Server 2000 2 May 3rd, 2007 05:18 PM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
INSERT INTO QUERY sanjna000 Excel VBA 5 November 26th, 2004 12:41 AM





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