473,626 Members | 3,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Number of query values and destination fields are not the same.

adascat
8 New Member
Could anyone find out the problem why this is happening? The number of query values I am trying to insert is exactly the same as in my accdb file actually.

Number of query values and destination fields are not the same.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on: Number of query values and destination fields are not the same.

Source Error:

Line 40: aQuery = aQuery & " Values ('" & PSW & "', '" & UsrName & "', '" & name & "', '" & Email & "', '" & Landline & "', '" & Website & "')"
Line 41: aCommand = New OleDbCommand(aQ uery, aConnection1)
Line 42: aCommand.Execut eNonQuery()
Line 43: aConnection1.Cl ose()
Line 44: lblResults.Text = "Your account has been created and please wait for approval from administrator"


Source File: C:\Users\Lili Wang\Documents\ Visual Studio 2010\Projects\W ebApplication1\ WebApplication1 \Registration_E mployer.aspx.vb Line: 42

Stack Trace:

[OleDbException (0x80004005): Number of query values and destination fields are not the same.]
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(OleDbHResult hr) +1070856
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S dbParams, Object& executeResult) +247
System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object& executeResult) +194
System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior, Object& executeResult) +58
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior behavior, String method) +167
System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y() +113
WebApplication1 .Registration_E mployer.Button1 _Click(Object sender, EventArgs e) in C:\Users\Lili Wang\Documents\ Visual Studio 2010\Projects\W ebApplication1\ WebApplication1 \Registration_E mployer.aspx.vb :42
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +118
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument) +112
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +10
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument) +13
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +36
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +5563




Expand|Select|Wrap|Line Numbers
  1. Imports System.Data
  2. Imports System.Data.OleDb
  3.  
  4. Partial Class Registration_Employer
  5.     Inherits System.Web.UI.Page
  6.  
  7.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  8.  
  9.     End Sub
  10.  
  11.     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
  12.         Dim aConnection, aConnection1 As OleDbConnection
  13.         Dim aConnectionString, aQuery As String
  14.         Dim aDataReader As OleDbDataReader
  15.         Dim aCommand As OleDbCommand
  16.  
  17.         Dim Email As String = txtEmail.Text
  18.         Dim PSW As String = ""
  19.         Dim UsrName As String = txtUsr.Text
  20.         Dim name As String = txtCompanyName.Text
  21.         Dim Landline As String = txtLandline.Text
  22.         Dim Website As String = txtWeb.Text
  23.  
  24.  
  25.         aConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & _
  26.                      Server.MapPath("/App_Data/CS5012ProjectAY201011.accdb")
  27.         aConnection = New OleDbConnection(aConnectionString)
  28.         aQuery = "Select TranslatorEmail from Translator where TranslatorEmail = '" & Email & "'"
  29.         aCommand = New OleDbCommand(aQuery, aConnection)
  30.         aConnection.Open()
  31.         aDataReader = aCommand.ExecuteReader
  32.  
  33.         If (aDataReader.Read() = True) Then
  34.             lblResults.Text = "Account already exists for this person"
  35.             Button1.Enabled = False
  36.         Else
  37.             aConnection1 = New OleDbConnection(aConnectionString)
  38.             aConnection1.Open()
  39.             aQuery = "Insert Into Employer "
  40.             aQuery = aQuery & " Values ('" & PSW & "', '" & UsrName & "', '" & name & "', '" & Email & "', '" & Landline & "', '" & Website & "')"
  41.             aCommand = New OleDbCommand(aQuery, aConnection1)
  42.             aCommand.ExecuteNonQuery()
  43.             aConnection1.Close()
  44.             lblResults.Text = "Your account has been created and please wait for approval from administrator"
  45.             Button1.Enabled = False
  46.         End If
  47.         aDataReader.Close()
  48.         aConnection.Close()
  49.  
  50.  
  51.     End Sub
  52.  
  53. End Class
May 3 '11 #1
3 4001
Rabbit
12,516 Recognized Expert Moderator MVP
This question can't be answered without knowing the definition of the employer table.
May 3 '11 #2
adascat
8 New Member
I've added the s.shot of employer table. haiz it's small.
There are 6 columns in the table:
EmployerPasswor d, EmployerNickNam e, CompanyName, CompanyEmail, CompanyTelephon e, CompanyURL, and one Click to Add.
Looking at design view, they are all TEXT datatype.
the DB is in accdb format, access 2007.
Attached Images
File Type: jpg Access 2007.jpg (33.6 KB, 330 views)
May 3 '11 #3
adascat
8 New Member
It's so interesting when you ask question about definition of the table it makes me re-look at the table and find out the issue. the click to add column is indeed taken as a column and i added an empty string to this column yes it worked out. Thank you :D
May 3 '11 #4

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

Similar topics

3
4460
by: Gert Jan Wiersema | last post by:
Hello all, I'm trying to give users a form in which they can check all 52 weeks of the year. This is done in a $weeks_array thingy. Unfortunately it seems that only 46 of the 52 values (and some other hidden values such as username etc) make it to the next page ($n 0-45). Is there a limit of values in forms? thanx, gert
1
2642
by: Mike | last post by:
My users have to select an value from a fixed selection of values. The obvious choice of control for such a requirement is to use a <select> (i.e. a combo box). My problem is that sometimes, these combo boxes will have a *large* number of values. There could be any number of values in them from 5 to 5 million (unlikely it would be this large but possible). Obviously 5 million is far too much to populate a <select> control with. Does...
3
3455
by: Zb Bornemann | last post by:
Hi All, Ok. Here's what my table looks like: Field1 Field2 Field3 Field4... Record1 1 3 2 9 Record2 9 1 9 4 Record3 1 3 1 2 etc, etc. What I want to do is for each record, count the number of values across the
2
8138
by: ralamo | last post by:
When i execute the following insert query, the above mentioned error is coming. Anything wrong in the query? INSERT INTO ECN_1 (Old_SbPartNo, Old_PartDesc, Old_ManPartNo, Old_Manuf, Old_Vendor, Old_RefDesi, Old_Qty, New_SbPartNo, New_PartDesc, New_ManPartNo,New_Manuf, New_Vendor, New_RefDesi, New_Qty) select * from (select SB0014.SbPartNo, SB0014.partDesc, SB0014.mANpARTnO, SB0014.manufacturer,
3
1722
by: kathyburke40 | last post by:
Odd problem. I have a table in the following format: DocID Question1 Question2 Question3 ------------------------------------------------ 298 1, 2, 3 or 0 Each Question field will have 1,2,3 or 0 if not completed. The number of Question fields will vary. I need to count all the questions, then figure out how many have 0
9
3359
by: Kosmos | last post by:
I'm getting this error message: Number of query values and destination fields are not the same. This is the code: INSERT INTO tblDateDifference ( DateDifference ) SELECT tblContracts.EndDate As EndDate, IIf( > EndDate, DaysToCompletion(EndDate), DaysCompleted(EndDate)) AS DateDifference, FROM tblContracts; Can someone please tell me why I'm getting this error message? PLEASE?!?! lol
0
1423
by: R Bandeira | last post by:
How to keep values in fields after ChangeMode to Insert from Edit? I am implementing a re-insert type feature, after an edit. // Change form to insert mode FormView1.ChangeMode(FormViewMode.Insert); // Repopulate the form Label.Text = "12345"; TextBox.Text = "22";
2
5907
by: cypriot | last post by:
Hi. I am developing an application program in java. I use MsAccess for keeping data. I had a problem with sql insert method. public void AddPatient() { String no= numberinput.getText();
3
2857
by: monion | last post by:
One more question. How can I get query values assign them to a variable, but not show them? for example size, $f4 in the following: How can I pass that value $f4 to the form handle page to submit to the database. I can clearly see how to pass $f2 with quantity stuck on the end. Basically, I need to pass 3 things: 1) item#, 2) item#quantity and 3) size to a new database. mysql_select_db("inventory"); $query="SELECT * FROM...
0
8269
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8203
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8711
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7203
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.