System.InvalidCastException: Object must implement IConvertible ???

I have created a web page that saves the information that is input into a small access database.
When I click my save button I get the error page showing.

Its prob something simple but I'm a newbie to programming so help would be appreciated!!
Kev
____________________________________________________

System.InvalidCastException: Object must implement IConvertible.

[InvalidCastException: Object must implement IConvertible.]
   System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +122
   System.Data.OleDb.OleDbParameter.GetParameterValue() +173
   System.Data.OleDb.OleDbParameter.GetParameterScale() +28
   System.Data.OleDb.OleDbParameter.BindParameter(Int32 i, DBBindings bindings, tagDBPARAMBINDINFO[] bindInfo) +129
   System.Data.OleDb.OleDbCommand.CreateAccessor() +152
   System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior behavior, Boolean throwifnotsupported) +175
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +22
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +67
   ASP.new_quote_aspx.AddQuote(String title, String firstname, String surname, String housename, String houseNumber, String street, String locality, String town, String county, String postcode, String hometel, String worktel, String mobtel, String email, Boolean pWindows, Boolean pDoors, Boolean pRoofline, Boolean pGaragedoors) +2423
   ASP.new_quote_aspx.btnSave_Click(Object sender, EventArgs e) +306
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1292
LVL 5
KevNetAsked:
Who is Participating?
 
ihenryCommented:
dbParam_pWindows.Value = chkWindows
dbParam_pDoors.Value = chkDoors
...
...
let me guess, checkboxes? that should be

dbParam_pWindows.Value = chkWindows.Checked
dbParam_pDoors.Value = chkDoors.Checked
....
...
0
 
ihenryCommented:
The error is usually becaused of passing an unacceptable object value to OleDbParameter. Please post your code which creating the OleDbParameter parameters, it should be able to show what's wrong in there.
0
 
KevNetAuthor Commented:
Function AddQuote( _
                ByVal title As String,  _
                ByVal firstname As String,  _
                ByVal surname As String,  _
                ByVal housename As String,  _
                ByVal houseNumber As string,  _
                ByVal street As String,  _
                ByVal locality As String,  _
                ByVal town As String,  _
                ByVal county As String,  _
                ByVal postcode As String,  _
                ByVal hometel As String,  _
                ByVal worktel As String,  _
                ByVal mobtel As String,  _
                ByVal email As String,  _
                ByVal pWindows As Boolean,  _
                ByVal pDoors As Boolean,  _
                ByVal pRoofline As Boolean,  _
                ByVal pGaragedoors As Boolean) As Integer
        Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=" & Server.MapPath("database/quotes.mdb")
        Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)

        Dim queryString As String = "INSERT INTO [quotes] ([Title], [Firstname], [Surname], [Housename], [HouseNumber]"& _
", [Street], [Locality], [Town], [County], [Postcode], [Hometel], [Worktel], [Mob"& _
"tel], [Email], [PWindows], [PDoors], [PRoofline], [PGaragedoors]) VALUES (@Title"& _
", @Firstname, @Surname, @Housename, @HouseNumber, @Street, @Locality, @Town, @Co"& _
"unty, @Postcode, @Hometel, @Worktel, @Mobtel, @Email, @PWindows, @PDoors, @PRoof"& _
"line, @PGaragedoors)"
        Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        Dim dbParam_title As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_title.ParameterName = "@Title"
        dbParam_title.Value = txtTitle.text
        dbParam_title.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_title)
        Dim dbParam_firstname As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_firstname.ParameterName = "@Firstname"
        dbParam_firstname.Value = txtfirstname.text
        dbParam_firstname.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_firstname)
        Dim dbParam_surname As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_surname.ParameterName = "@Surname"
        dbParam_surname.Value = txtsurname.text
        dbParam_surname.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_surname)
        Dim dbParam_housename As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_housename.ParameterName = "@Housename"
        dbParam_housename.Value = txthousename.text
        dbParam_housename.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_housename)
        Dim dbParam_houseNumber As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_houseNumber.ParameterName = "@HouseNumber"
        dbParam_houseNumber.Value = txthouseNo.text
        dbParam_houseNumber.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_houseNumber)
        Dim dbParam_street As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_street.ParameterName = "@Street"
        dbParam_street.Value = txtstreet.text
        dbParam_street.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_street)
        Dim dbParam_locality As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_locality.ParameterName = "@Locality"
        dbParam_locality.Value = txtlocality.text
        dbParam_locality.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_locality)
        Dim dbParam_town As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_town.ParameterName = "@Town"
        dbParam_town.Value = txttown.text
        dbParam_town.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_town)
        Dim dbParam_county As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_county.ParameterName = "@County"
        dbParam_county.Value = txtcounty.text
        dbParam_county.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_county)
        Dim dbParam_postcode As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_postcode.ParameterName = "@Postcode"
        dbParam_postcode.Value = txtpostcode.text
        dbParam_postcode.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_postcode)
        Dim dbParam_hometel As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_hometel.ParameterName = "@Hometel"
        dbParam_hometel.Value = txthometel.text
        dbParam_hometel.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_hometel)
        Dim dbParam_worktel As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_worktel.ParameterName = "@Worktel"
        dbParam_worktel.Value = txtworktel.text
        dbParam_worktel.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_worktel)
        Dim dbParam_mobtel As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_mobtel.ParameterName = "@Mobtel"
        dbParam_mobtel.Value = txtmobtel.text
        dbParam_mobtel.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_mobtel)
        Dim dbParam_email As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_email.ParameterName = "@Email"
        dbParam_email.Value = txtemail.text
        dbParam_email.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_email)
        Dim dbParam_pWindows As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_pWindows.ParameterName = "@PWindows"
        dbParam_pWindows.Value = chkWindows
        dbParam_pWindows.DbType = System.Data.DbType.Boolean
        dbCommand.Parameters.Add(dbParam_pWindows)
        Dim dbParam_pDoors As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_pDoors.ParameterName = "@PDoors"
        dbParam_pDoors.Value = chkDoors
        dbParam_pDoors.DbType = System.Data.DbType.Boolean
        dbCommand.Parameters.Add(dbParam_pDoors)
        Dim dbParam_pRoofline As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_pRoofline.ParameterName = "@PRoofline"
        dbParam_pRoofline.Value = chkRoofline
        dbParam_pRoofline.DbType = System.Data.DbType.Boolean
        dbCommand.Parameters.Add(dbParam_pRoofline)
        Dim dbParam_pGaragedoors As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_pGaragedoors.ParameterName = "@PGaragedoors"
        dbParam_pGaragedoors.Value = chkGaragedoors
        dbParam_pGaragedoors.DbType = System.Data.DbType.Boolean
        dbCommand.Parameters.Add(dbParam_pGaragedoors)

        Dim rowsAffected As Integer = 0
        dbConnection.Open
        Try
            rowsAffected = dbCommand.ExecuteNonQuery
        Finally
            dbConnection.Close
        End Try

        Return rowsAffected
    End Function
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.