none
Unable to cast object of type 'RecipeDataTable' to type 'System.IConvertible'.Couldn't store <Recipe> in RECIPE_ID Column. Expected type is Decimal. RRS feed

  • Question

  • Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
    Try
    ' Dim drCurrent As DataRow
    'Dim temp As Kdd_Web_PageLinksTableAdapters.RecipeTA
    Dim FU As New FileUpload
    Dim X As New Kdd_Web_PageLinks.RecipeDataTable
    Dim r As Kdd_Web_PageLinks.RecipeRow
    r = X.NewRecipeRow()
    r.RECIPE_ID = 0
    r.RECIPE_MENUID = txtRecipe_MenuId.Text
    r.RECIPE_TITLE = txtRecipe_Title.Text
    r.RECIPE_DESCRIPTION = txtRecipe_Description.Text
    r.RECIPE_IMAGE = "jpg"
    r.RECIPE_ISNEW = 1
    r.RECIPE_ISAPPROVED = 1
    r.RECIPE_ISKDD = 1
    r.CREATED_BY = 0
    r.CREATION_DATE = "1/JAN/09"
    r.LAST_UPDATED_BY = 0
    r.LAST_UPDATE_DATE = "2/JAN/09"
    r.Table.Rows.Add(X)
    MsgBox(X.Count)
    Catch ex As Exception
    MsgBox(ex.ToString)
    End Try
    End Sub

    I am trying to add data into databse through datatable This is my code and in that Recipe Id is autonumber.. but when i am trying to add i am getting this error :- "Unable to cast object of type 'RecipeDataTable' to type 'System.IConvertible'.Couldn't store in RECIPE_ID Column. Expected type is Decimal." Kindly give me the solution so that i can Insert data
    • Edited by VMazurModerator Monday, December 7, 2009 11:11 AM posted code was messed up
    Sunday, December 6, 2009 11:55 AM

Answers