Home All Groups Group Topic Archive Search About
Author
19 May 2006 4:12 PM
Joe Delphi
Hi,

       I am attempting to do an INSERT operation using the OleDBCommand
object.   I am receiving this error message:

       "Object must implement IConvertible"

       Here is the part of my code where the error occurs:

Dim cmdInsert As System.Data.OleDb.OleDbCommand
  cmdInsert = Me.daChangeRequests.InsertCommand
With cmdInsert
  .Parameters(0).Value = Me.txtTitle.Text
  .Parameters(1).Value = Me.txtDescription.Text
  .Parameters(2).Value = Me.ddlstPriority.SelectedItem
  .Parameters(3).Value = Me.ddlstStatus.SelectedItem
  .Parameters(4).Value = Me.ddlstSubBy.SelectedItem
  .Parameters(5).Value = Today
  .Parameters(6).Value = Me.txtNotes.Text
  .Parameters(7).Value = Me.ddlstStatus.SelectedItem
  .Parameters(8).Value = Me.txtDateFixed.Text
End With

'Now INSERT the record into the database, and let the user
'know if something went wrong with the INSERT.

cnChangeRequests.Open()

Try
cmdInsert.ExecuteNonQuery()
Me.lblSaved.ForeColor = White
Me.lblSaved.Text = "CR successfully saved."
Catch
Me.lblSaved.ForeColor = Red
Me.lblSaved.Text = Err.Description
cnChangeRequests.Close()
Exit Sub
End Try

cnChangeRequests.Close()



          Can anyone tell me what I am doing wrong?

JD

Author
19 May 2006 4:39 PM
Marina Levit [MVP]
It would be quite helpful if you told us which line actually causes the
error.

My guess is, it is one of the lines where you are assigning parameter
values.  You are assigning SelectedItem, which is not the expected type and
cannot be converted to the expected type.  Do yourself a favor and always
use Option Strict On, if this is the case.

"Joe Delphi" <delphi561@nospam.cox.net> wrote in message
news:88mbg.2223$rS6.1273@fed1read11...
Show quote
> Hi,
>
>       I am attempting to do an INSERT operation using the OleDBCommand
> object.   I am receiving this error message:
>
>       "Object must implement IConvertible"
>
>       Here is the part of my code where the error occurs:
>
> Dim cmdInsert As System.Data.OleDb.OleDbCommand
>  cmdInsert = Me.daChangeRequests.InsertCommand
> With cmdInsert
>  .Parameters(0).Value = Me.txtTitle.Text
>  .Parameters(1).Value = Me.txtDescription.Text
>  .Parameters(2).Value = Me.ddlstPriority.SelectedItem
>  .Parameters(3).Value = Me.ddlstStatus.SelectedItem
>  .Parameters(4).Value = Me.ddlstSubBy.SelectedItem
>  .Parameters(5).Value = Today
>  .Parameters(6).Value = Me.txtNotes.Text
>  .Parameters(7).Value = Me.ddlstStatus.SelectedItem
>  .Parameters(8).Value = Me.txtDateFixed.Text
> End With
>
> 'Now INSERT the record into the database, and let the user
> 'know if something went wrong with the INSERT.
>
> cnChangeRequests.Open()
>
> Try
> cmdInsert.ExecuteNonQuery()
> Me.lblSaved.ForeColor = White
> Me.lblSaved.Text = "CR successfully saved."
> Catch
> Me.lblSaved.ForeColor = Red
> Me.lblSaved.Text = Err.Description
> cnChangeRequests.Close()
> Exit Sub
> End Try
>
> cnChangeRequests.Close()
>
>
>
>          Can anyone tell me what I am doing wrong?
>
> JD
>
>
Author
19 May 2006 11:13 PM
MSDN
This is your problem:  Value = Me.ddlstPriority.SelectedItem
might want

..Parameter(x).Value = Me.ddlstPriority.SelectedItem.value
or
..Parameter(x).Value = Value = Me.ddlstPriority.SelectedItem.text

SA


"Joe Delphi" <delphi561@nospam.cox.net> wrote in message
news:88mbg.2223$rS6.1273@fed1read11...
Show quote
> Hi,
>
>       I am attempting to do an INSERT operation using the OleDBCommand
> object.   I am receiving this error message:
>
>       "Object must implement IConvertible"
>
>       Here is the part of my code where the error occurs:
>
> Dim cmdInsert As System.Data.OleDb.OleDbCommand
>  cmdInsert = Me.daChangeRequests.InsertCommand
> With cmdInsert
>  .Parameters(0).Value = Me.txtTitle.Text
>  .Parameters(1).Value = Me.txtDescription.Text
>  .Parameters(2).Value = Me.ddlstPriority.SelectedItem
>  .Parameters(3).Value = Me.ddlstStatus.SelectedItem
>  .Parameters(4).Value = Me.ddlstSubBy.SelectedItem
>  .Parameters(5).Value = Today
>  .Parameters(6).Value = Me.txtNotes.Text
>  .Parameters(7).Value = Me.ddlstStatus.SelectedItem
>  .Parameters(8).Value = Me.txtDateFixed.Text
> End With
>
> 'Now INSERT the record into the database, and let the user
> 'know if something went wrong with the INSERT.
>
> cnChangeRequests.Open()
>
> Try
> cmdInsert.ExecuteNonQuery()
> Me.lblSaved.ForeColor = White
> Me.lblSaved.Text = "CR successfully saved."
> Catch
> Me.lblSaved.ForeColor = Red
> Me.lblSaved.Text = Err.Description
> cnChangeRequests.Close()
> Exit Sub
> End Try
>
> cnChangeRequests.Close()
>
>
>
>          Can anyone tell me what I am doing wrong?
>
> JD
>
>

AddThis Social Bookmark Button