473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

adascat
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.OleDb.OleDbException: 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(aQuery, aConnection1)
Line 42: aCommand.ExecuteNonQuery()
Line 43: aConnection1.Close()
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\WebApplication1\WebApplication1\Regi stration_Employer.aspx.vb Line: 42

Stack Trace:

[OleDbException (0x80004005): Number of query values and destination fields are not the same.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(OleDbHResult hr) +1070856
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) +194
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) +167
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +113
WebApplication1.Registration_Employer.Button1_Clic k(Object sender, EventArgs e) in C:\Users\Lili Wang\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\Regi stration_Employer.aspx.vb:42
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +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

✓ answered by Rabbit

This question can't be answered without knowing the definition of the employer table.

3 3987
Rabbit
12,516 Expert Mod 8TB
This question can't be answered without knowing the definition of the employer table.
May 3 '11 #2
I've added the s.shot of employer table. haiz it's small.
There are 6 columns in the table:
EmployerPassword, EmployerNickName, CompanyName, CompanyEmail, CompanyTelephone, 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, 327 views)
May 3 '11 #3
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
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...
1
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,...
3
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 ...
2
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,...
3
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...
9
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...
0
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...
2
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.