G
Guest
Hello,
I can update a dataset from my client app using a dataAdapter.Updatecommand
when I add parameter values outside of the param declaration. But If I add
the param values inline with the param delcaration, then I have to invoke the
update operation twice - by leaving the updated row - returning to the row
and re-invoking the update procedure. Is there something else I need to do
to add param values inline with the param declaration?
param values added outside of param declaration - works OK:
Private Sub Button4_Click(...) Handles Button4.Click
Dim daU As New SqlDataAdapter
daU.UpdateCommand = New SqlCommand
daU.UpdateCommand.Connection = conn
daU.UpdateCommand.Parameters.Add(New SqlParameter("@p0", SqlDbType.Int))
daU.UpdateCommand.Parameters.Add(New SqlParameter("@p1", SqlDbType.VarChar,
50))
daU.UpdateCommand.CommandText = "Update tbl1 set tName = @p1 Where tID = @p0"
daU.UpdateCommand.Parameters("@p0").Value = txtID.Text
daU.UpdateCommand.Parameters("@p1").Value = txtTname.Text
daU.Update(ds, "tbl1")
End Sub
-----------------------------------------------------------------------------
param values added inline with param declaration - have to invoke twice to
get update - must leave row first and then return:
Private Sub Button4_Click(...) Handles Button4.Click
Dim daU As New SqlDataAdapter
daU.UpdateCommand = New SqlCommand
daU.UpdateCommand.Connection = conn
daU.UpdateCommand.Parameters.Add(New SqlParameter("@p0", SqlDbType.Int, 4,
"ID" ))
daU.UpdateCommand.Parameters.Add(New SqlParameter("@p1", SqlDbType.VarChar,
50, "tName"))
daU.UpdateCommand.CommandText = "Update tbl1 set tName = @p1 Where tID = @p0"
daU.Update(ds, "tbl1")
End Sub
--------------------------------------------------------------------------
Is there something else I need to do to Way2 to make it work when adding
param values inline with the param declaration?
Thanks,
Rich
I can update a dataset from my client app using a dataAdapter.Updatecommand
when I add parameter values outside of the param declaration. But If I add
the param values inline with the param delcaration, then I have to invoke the
update operation twice - by leaving the updated row - returning to the row
and re-invoking the update procedure. Is there something else I need to do
to add param values inline with the param declaration?
param values added outside of param declaration - works OK:
Private Sub Button4_Click(...) Handles Button4.Click
Dim daU As New SqlDataAdapter
daU.UpdateCommand = New SqlCommand
daU.UpdateCommand.Connection = conn
daU.UpdateCommand.Parameters.Add(New SqlParameter("@p0", SqlDbType.Int))
daU.UpdateCommand.Parameters.Add(New SqlParameter("@p1", SqlDbType.VarChar,
50))
daU.UpdateCommand.CommandText = "Update tbl1 set tName = @p1 Where tID = @p0"
daU.UpdateCommand.Parameters("@p0").Value = txtID.Text
daU.UpdateCommand.Parameters("@p1").Value = txtTname.Text
daU.Update(ds, "tbl1")
End Sub
-----------------------------------------------------------------------------
param values added inline with param declaration - have to invoke twice to
get update - must leave row first and then return:
Private Sub Button4_Click(...) Handles Button4.Click
Dim daU As New SqlDataAdapter
daU.UpdateCommand = New SqlCommand
daU.UpdateCommand.Connection = conn
daU.UpdateCommand.Parameters.Add(New SqlParameter("@p0", SqlDbType.Int, 4,
"ID" ))
daU.UpdateCommand.Parameters.Add(New SqlParameter("@p1", SqlDbType.VarChar,
50, "tName"))
daU.UpdateCommand.CommandText = "Update tbl1 set tName = @p1 Where tID = @p0"
daU.Update(ds, "tbl1")
End Sub
--------------------------------------------------------------------------
Is there something else I need to do to Way2 to make it work when adding
param values inline with the param declaration?
Thanks,
Rich