I am using a dataadapter, stored procedure.. I had it updating correctly, but now it's not... I changed it over from being a dynamic Datagrid to using a DS/DA/Connection thru the design instead of at runtime. But my update will still be at runtime since it uses another Stored Procedure to update the DB...
There are a couple of things it's doing
1. it's updating all the records w/ same value, even thought it's suppose to be diff. I thought it was the Datakey. And I'm not sure about datakeys, because it's the 2nd column in my datagrid, and is a string like (aaa123)
2. I have to push the update button 2x's to get the update to go thru..
Here is my code
ANY HELP WOULD BE HELPFULL THANKS
There are a couple of things it's doing
1. it's updating all the records w/ same value, even thought it's suppose to be diff. I thought it was the Datakey. And I'm not sure about datakeys, because it's the 2nd column in my datagrid, and is a string like (aaa123)
2. I have to push the update button 2x's to get the update to go thru..
Here is my code
Code:
Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
Dim Dgi As DataGridItem
Dim MoEnd As String
For Each Dgi In Me.Dg.Items
Dim ClientID As String = Convert.ToString(Dg.DataKeys(Dgi.ItemIndex))
'Dim ClientID As String = Dg.DataKeys(Dgi.ItemIndex).ToString
Dim ClientValue As String = CType(Dgi.FindControl("HypCliId"), HyperLink).Text
Dim DueDate As String = CType(Dgi.FindControl("txtDueDate"), TextBox).Text
Dim RptPriority As String = CType(Dgi.FindControl("txtRptPriority"), TextBox).Text
MoEnd = Me.TextBox1.Text
Dim ClientParam As New SqlParameter("@ClientID", SqlDbType.VarChar)
ClientParam.Direction = ParameterDirection.Input
Dim MoEndParam As New SqlParameter("@MoEnd", SqlDbType.VarChar, 10)
MoEndParam.Direction = ParameterDirection.Input
Dim DueDateParam As New SqlParameter("@DueDate", SqlDbType.VarChar, 10)
DueDateParam.Direction = ParameterDirection.Input
Dim PriorityParam As New SqlParameter("@Priority", SqlDbType.VarChar)
PriorityParam.Direction = ParameterDirection.Input
Dim DaUpdate As New SqlDataAdapter
DaUpdate.UpdateCommand = New SqlCommand
DaUpdate.UpdateCommand.Connection = SqlConn
DaUpdate.UpdateCommand.CommandText = "Stp_UpdateChecklist"
DaUpdate.UpdateCommand.CommandType = CommandType.StoredProcedure
DaUpdate.UpdateCommand.Parameters.Add(ClientParam)
DaUpdate.UpdateCommand.Parameters("@ClientID").Value = ClientValue
DaUpdate.UpdateCommand.Parameters.Add(MoEndParam)
DaUpdate.UpdateCommand.Parameters("@MoEnd").Value = MoEnd
DaUpdate.UpdateCommand.Parameters.Add(DueDateParam)
DaUpdate.UpdateCommand.Parameters("@DueDate").Value = "2/23/2005"
DaUpdate.UpdateCommand.Parameters.Add(PriorityParam)
DaUpdate.UpdateCommand.Parameters("@Priority").Value = "A"
SqlConn.Open()
DaUpdate.UpdateCommand.ExecuteNonQuery()
SqlConn.Close()
Next
end sub
ANY HELP WOULD BE HELPFULL THANKS