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
- Imports System.Data
- Imports System.Data.OleDb
- Partial Class Registration_Employer
- Inherits System.Web.UI.Page
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- End Sub
- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
- Dim aConnection, aConnection1 As OleDbConnection
- Dim aConnectionString, aQuery As String
- Dim aDataReader As OleDbDataReader
- Dim aCommand As OleDbCommand
- Dim Email As String = txtEmail.Text
- Dim PSW As String = ""
- Dim UsrName As String = txtUsr.Text
- Dim name As String = txtCompanyName.Text
- Dim Landline As String = txtLandline.Text
- Dim Website As String = txtWeb.Text
- aConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & _
- Server.MapPath("/App_Data/CS5012ProjectAY201011.accdb")
- aConnection = New OleDbConnection(aConnectionString)
- aQuery = "Select TranslatorEmail from Translator where TranslatorEmail = '" & Email & "'"
- aCommand = New OleDbCommand(aQuery, aConnection)
- aConnection.Open()
- aDataReader = aCommand.ExecuteReader
- If (aDataReader.Read() = True) Then
- lblResults.Text = "Account already exists for this person"
- Button1.Enabled = False
- Else
- aConnection1 = New OleDbConnection(aConnectionString)
- aConnection1.Open()
- aQuery = "Insert Into Employer "
- aQuery = aQuery & " Values ('" & PSW & "', '" & UsrName & "', '" & name & "', '" & Email & "', '" & Landline & "', '" & Website & "')"
- aCommand = New OleDbCommand(aQuery, aConnection1)
- aCommand.ExecuteNonQuery()
- aConnection1.Close()
- lblResults.Text = "Your account has been created and please wait for approval from administrator"
- Button1.Enabled = False
- End If
- aDataReader.Close()
- aConnection.Close()
- End Sub
- End Class