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
- 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