Prepared Statement expects parameter

rvermeulen

Member
Joined
Apr 2, 2003
Messages
17
Location
New Jersey
Hi folks,

Im getting an error when I attempt to edit a record in my datagrid through a dataset. Im able to load the grid and select the edit link button which brings the record in Edit mode. In my dataset, I have two dataadapters (one with employee information and another with Job descriptions) that I use to display employee information and the employee Job in the grid. The employee info is in the grid, the job description is a label in a template column. So for a particular employee, you see information and then his Job description as opposed to the jobid on the employee table.
Once the record goes into Edit mode, the job description label becomes a drop down list with a list of all possible Job descriptions, and the employees current job description selected. When I click the Update link button, I get the following error:

Prepared statement (@JobID int, @JobDescr varchar(50), @Original_JobID int, @Original_ expects parameter @JobDescr, which was not supplied.

The source error shows the following line as the error:
sqldataadapter1.update(DsJobsEdit1, "employees")


Here is my code:
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Put user code to initialize the page here
        If Not Page.IsPostBack Then
            SqlConnection1.Open()

            SqlDataAdapter1.Fill(DsJobsEdit1, "jobs")
            SqlDataAdapter2.Fill(DsJobsEdit1, "employees")

            dgEditGrid.DataBind()
        End If
    End Sub

    Public Function BindJob(ByVal o As Object) As String
        Dim drv As DataRowView = o
        Dim dr As dsJobsEdit.EMPLOYEESRow = drv.Row
        Return dr.JOBSRow.JobDescr

    End Function

    Private Sub reBind()

        SqlDataAdapter1.Fill(DsJobsEdit1, "jobs")
        SqlDataAdapter2.Fill(DsJobsEdit1, "employees")
        dgEditGrid.DataBind()

    End Sub

    Public Sub EditCommand(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)
        dgEditGrid.EditItemIndex = e.Item.ItemIndex
        reBind()

    End Sub

    Public Sub DeleteCommand(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)
        dgEditGrid.EditItemIndex = -1
        reBind()

    End Sub

    Public Sub CancelCommand(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)
        dgEditGrid.EditItemIndex = -1
        reBind()

    End Sub

    Public Sub UpdateCommand(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)
        reBind()
        Dim dr As dsJobsEdit.EMPLOYEESRow = DsJobsEdit1.EMPLOYEES.Item(e.Item.DataSetIndex)
        Dim ddljobs As DropDownList
        ddljobs = e.Item.FindControl("ddlbJobs")
        dr.JobID = ddljobs.SelectedItem.Value
        SqlDataAdapter1.Update(DsJobsEdit1, "employees")
        dgEditGrid.EditItemIndex = -1
        reBind()
    End Sub

    Public Sub ItemDataBound(ByVal Sender As Object, ByVal e As DataGridItemEventArgs)
        Dim lit As ListItemType = e.Item.ItemType
        If lit = ListItemType.EditItem Then
            Dim ddlbjobs As DropDownList
            ddlbjobs = e.Item.FindControl("ddlbjobs")

            Dim drv As DataRowView = e.Item.DataItem
            If Not drv Is Nothing Then
                ddlbjobs.Items.FindByValue(drv("jobid")).Selected = True
            End If
        End If

    End Sub

Can anyone please help.
Thanks in advance.
Rick
[edit]Please use
Code:
 tags [/ vb][/edit][/COLOR]
 
Last edited by a moderator:
Back
Top