I'm having a problem with updating a record through a form.
Here is the error:
[HTML]Server Error in '/AccoEndUser' Application.
--------------------------------------------------------------------------------
Must declare the variable '@Title'.
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: Must declare the variable '@Title'.
Source Error:
Line 202: objConn.open()
Line 203:
Line 204: objCmd.ExecuteN onQuery()
Line 205:
Line 206: objConn.close()[/HTML]
And here is my code:
[HTML]<!-- #include file="includes/acco_inc.aspx"-->
<%@ import namespace="Syst em.Data" %>
<%@ import namespace="Syst em.Data.OleDb" %>
<Script Language="VB" Runat="Server">
dim objCmd As OleDbCommand
dim objRdr As OleDbDataReader
dim strCmd As String
sub UpdateRec(s As Object, e As EventArgs)
dim dsn As String = ConfigurationSe ttings.AppSetti ngs("SystemConn ection")
dim objConn as New OleDbConnection (dsn)
objCmd = New OleDbCommand("U PDATE tbl_ACCO_EU_Con tacts SET Title=@Title, FirstName=@Firs tName, LastName=@LastN ame, CompanyPosition =@CompanyPositi on, CompanyName=@Co mpanyName, CompanyAddress1 =@CompanyAddres s1, CompanyAddress2 =@CompanyAddres s2, CompanyAddress3 =@CompanyAddres s3, CompanyAddress4 =@CompanyAddres s4, CompanyTown=@Co mpanyTown, CompanyCounty=@ CompanyCounty, CompanyPostcode =@CompanyPostco de, CompanyEMailAdd ress=@CompanyEM ailAddress, CompanyTelephon e=@CompanyTelep hone, CompanyFax=@Com panyFax, CompanyDirectDi al=@CompanyDire ctDial, CompanyWebAddre ss=@CompanyWebA ddress, CompanySIC=@Com panySIC, CompanySize=@Co mpanySize, PersonalAddress 1=@PersonalAddr ess1, PersonalAddress 3=@PersonalAddr ess3, PersonalAddress 4=@PersonalAddr ess4, PersonalTown=@P ersonalTown, PersonalCounty= @PersonalCounty , PersonalPostCod e=@PersonalPost Code, PersonalCountry =@PersonalCount ry WHRER EndUserID=@EndU serID" , objConn )
objCmd.Paramete rs.Add("@Title" , textTitle.Text)
objCmd.Paramete rs.Add("@FirstN ame", textFirstName.T ext)
objCmd.Paramete rs.Add("@LastNa me", textLastName.Te xt)
objCmd.Paramete rs.Add("@Compan yPosition", textCompanyPosi tion.Text)
objCmd.Paramete rs.Add("@Compan yName", textCompanyName .Text)
objCmd.Paramete rs.Add("@Compan yAddress1", textCompanyAddr ess1.Text)
objCmd.Paramete rs.Add("@Compan yAddress2", textCompanyAddr ess2.Text)
objCmd.Paramete rs.Add("@Compan yAddress3", textCompanyAddr ess3.Text)
objCmd.Paramete rs.Add("@Compan yAddress4", textCompanyAddr ess4.Text)
objCmd.Paramete rs.Add("@Compan yTown", textCompanyTown .Text)
objCmd.Paramete rs.Add("@Compan yCounty", textCompanyCoun ty.Text)
objCmd.Paramete rs.Add("@Compan yPostcode", textCompanyPost code.Text)
objCmd.Paramete rs.Add("@Compan yEMailAddress", textCompanyEMai lAddress.Text)
objCmd.Paramete rs.Add("@Compan yTelephone", textCompanyTele phone.Text)
objCmd.Paramete rs.Add("@Compan yFax", textCompanyFax. Text)
objCmd.Paramete rs.Add("@Compan yDirectDial", textCompanyDire ctDial.Text)
objCmd.Paramete rs.Add("@Compan yWebAddress", textCompanyWebA ddress.Text)
objCmd.Paramete rs.Add("@Compan ySIC", textCompanySIC. Text)
objCmd.Paramete rs.Add("@Compan ySize", textCompanySize .Text)
objCmd.Paramete rs.Add("@Person alAddress1", textPersonalAdd ress1.Text)
objCmd.Paramete rs.Add("@Person alAddress2", textPersonalAdd ress2.Text)
objCmd.Paramete rs.Add("@Person alAddress3", textPersonalAdd ress3.Text)
objCmd.Paramete rs.Add("@Person alAddress4", textPersonalAdd ress4.Text)
objCmd.Paramete rs.Add("@Person alTown", textPersonalTow n.Text)
objCmd.Paramete rs.Add("@Person alCounty", textPersonalCou nty.Text)
objCmd.Paramete rs.Add("@Person alPostCode", textPersonalPos tCode.Text)
objConn.open()
objCmd.ExecuteN onQuery()
objConn.close()
end sub
</script>[/HTML]
Any ideas would be great.
Cheers
Adz