G
Guest
Can someone please tell me why I keep getting the following error??? I can't
seem to see what is causing the problem... Any help would be greatly
appritiated!
Thanks
System.InvalidCastException: Object must implement IConvertible.
Line 154: 'objStatusS.Value = fldRSVPs
Line 155:
Line 156: Dim myReader As OleDbDataReader = cmd.ExecuteReader ' Error
Line 157: myReader.Read()
Code:::
Sub UpdateData(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnSubmit.Click
Dim Titleg As String = CType(FindControl("txtTitle"), TextBox).Text
Dim Firstnameg As String = CType(FindControl("txtFirstName"),
TextBox).Text
Dim Lastnameg As String = CType(FindControl("txtLastName"),
TextBox).Text
Dim Statusg As String = CType(FindControl("fldRSVPg"),
RadioButtonList).SelectedItem.Value
Dim Titles As String = CType(FindControl("txtTitles"), TextBox).Text
Dim Firstnames As String = CType(FindControl("txtFirstNames"),
TextBox).Text
Dim Lastnames As String = CType(FindControl("txtLastNames"),
TextBox).Text
Dim Statuss As String = CType(FindControl("fldRSVPs"),
RadioButtonList).SelectedItem.Value
Dim strSQL As String
Dim objConn As OleDbConnection
Dim cmd As OleDbCommand
Dim strSalutation As String
Dim strLastName As String
Dim strFirstName As String
Dim strSalutationS As String
Dim strLastNameS As String
Dim strFirstNameS As String
strSQL = "UPDATE(Person) SET Salutation = '" & strSalutation & "',
Lastname = '" & strLastName & "' , Firstname = '" & strFirstName & "',
SalutationOfPartner = '" & strSalutationS & "' , LastnameOfPartner = '" &
strLastNameS & "', FirstnameOfPartner = '" & strFirstNameS & "' WHERE '" & ID
& "' = LocalIDNumber"
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
cmd = New OleDbCommand(strSQL, objConn)
'Try
objConn.Open()
Dim objTitleG, objFirstNameG, objLastNameG, objStatusG, objTitleS,
objFirstNameS, objLastNameS, objStatusS As OleDbParameter
objTitleG = cmd.Parameters.Add(strSalutation, OleDbType.VarChar)
objTitleG.Direction = ParameterDirection.Input
objTitleG.Value = txtTitle
objFirstNameG = cmd.Parameters.Add(strFirstName, OleDbType.VarChar)
objFirstNameG.Direction = ParameterDirection.Input
objFirstNameG.Value = txtFirstName
objLastNameG = cmd.Parameters.Add(strLastName, OleDbType.VarChar)
objLastNameG.Direction = ParameterDirection.Input
objLastNameG.Value = txtLastName
'objStatusG = cmd.Parameters.Add("????", OleDbType.VarChar)
'objStatusG.Direction = ParameterDirection.Input
'objStatusG.Value = fldRSVPg
objTitleS = cmd.Parameters.Add(strSalutationS, OleDbType.VarChar)
objTitleS.Direction = ParameterDirection.Input
objTitleS.Value = txtTitleS
objFirstNameS = cmd.Parameters.Add(strFirstNameS, OleDbType.VarChar)
objFirstNameS.Direction = ParameterDirection.Input
objFirstNameS.Value = txtFirstNameS
objLastNameS = cmd.Parameters.Add(strLastNameS, OleDbType.VarChar)
objLastNameS.Direction = ParameterDirection.Input
objLastNameS.Value = txtLastnameS
'objStatusS = cmd.Parameters.Add("????", OleDbType.VarChar)
'objStatusS.Direction = ParameterDirection.Input
'objStatusS.Value = fldRSVPs
Dim myReader As OleDbDataReader = cmd.ExecuteReader
myReader.Read()
myReader.Close()
' Catch ex As Exception
' lblMessage.Visible = True
' lblMessage.Text = "Error: Data could not be updated. Please
contact your systems administrator if this error persists..."
' Finally
objConn.Close()
' End Try
End Sub
seem to see what is causing the problem... Any help would be greatly
appritiated!
Thanks
System.InvalidCastException: Object must implement IConvertible.
Line 154: 'objStatusS.Value = fldRSVPs
Line 155:
Line 156: Dim myReader As OleDbDataReader = cmd.ExecuteReader ' Error
Line 157: myReader.Read()
Code:::
Sub UpdateData(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnSubmit.Click
Dim Titleg As String = CType(FindControl("txtTitle"), TextBox).Text
Dim Firstnameg As String = CType(FindControl("txtFirstName"),
TextBox).Text
Dim Lastnameg As String = CType(FindControl("txtLastName"),
TextBox).Text
Dim Statusg As String = CType(FindControl("fldRSVPg"),
RadioButtonList).SelectedItem.Value
Dim Titles As String = CType(FindControl("txtTitles"), TextBox).Text
Dim Firstnames As String = CType(FindControl("txtFirstNames"),
TextBox).Text
Dim Lastnames As String = CType(FindControl("txtLastNames"),
TextBox).Text
Dim Statuss As String = CType(FindControl("fldRSVPs"),
RadioButtonList).SelectedItem.Value
Dim strSQL As String
Dim objConn As OleDbConnection
Dim cmd As OleDbCommand
Dim strSalutation As String
Dim strLastName As String
Dim strFirstName As String
Dim strSalutationS As String
Dim strLastNameS As String
Dim strFirstNameS As String
strSQL = "UPDATE(Person) SET Salutation = '" & strSalutation & "',
Lastname = '" & strLastName & "' , Firstname = '" & strFirstName & "',
SalutationOfPartner = '" & strSalutationS & "' , LastnameOfPartner = '" &
strLastNameS & "', FirstnameOfPartner = '" & strFirstNameS & "' WHERE '" & ID
& "' = LocalIDNumber"
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
cmd = New OleDbCommand(strSQL, objConn)
'Try
objConn.Open()
Dim objTitleG, objFirstNameG, objLastNameG, objStatusG, objTitleS,
objFirstNameS, objLastNameS, objStatusS As OleDbParameter
objTitleG = cmd.Parameters.Add(strSalutation, OleDbType.VarChar)
objTitleG.Direction = ParameterDirection.Input
objTitleG.Value = txtTitle
objFirstNameG = cmd.Parameters.Add(strFirstName, OleDbType.VarChar)
objFirstNameG.Direction = ParameterDirection.Input
objFirstNameG.Value = txtFirstName
objLastNameG = cmd.Parameters.Add(strLastName, OleDbType.VarChar)
objLastNameG.Direction = ParameterDirection.Input
objLastNameG.Value = txtLastName
'objStatusG = cmd.Parameters.Add("????", OleDbType.VarChar)
'objStatusG.Direction = ParameterDirection.Input
'objStatusG.Value = fldRSVPg
objTitleS = cmd.Parameters.Add(strSalutationS, OleDbType.VarChar)
objTitleS.Direction = ParameterDirection.Input
objTitleS.Value = txtTitleS
objFirstNameS = cmd.Parameters.Add(strFirstNameS, OleDbType.VarChar)
objFirstNameS.Direction = ParameterDirection.Input
objFirstNameS.Value = txtFirstNameS
objLastNameS = cmd.Parameters.Add(strLastNameS, OleDbType.VarChar)
objLastNameS.Direction = ParameterDirection.Input
objLastNameS.Value = txtLastnameS
'objStatusS = cmd.Parameters.Add("????", OleDbType.VarChar)
'objStatusS.Direction = ParameterDirection.Input
'objStatusS.Value = fldRSVPs
Dim myReader As OleDbDataReader = cmd.ExecuteReader
myReader.Read()
myReader.Close()
' Catch ex As Exception
' lblMessage.Visible = True
' lblMessage.Text = "Error: Data could not be updated. Please
contact your systems administrator if this error persists..."
' Finally
objConn.Close()
' End Try
End Sub