S
Stan Sainte-Rose
Hi
I change my oledb namespace to sql namespace, and I have several problems
with the update command.
It worked fine with oledb but now, I drive me crazy.
And it happens for each of my update datatables.
By the way, I thank you for your help on my previous posts.
Stan
Here's a bit of my code :
strSQL = "Select code,ncdeclient FROM A_PARAM WHERE CODE='" &
stID + & "'"
daParam = New SqlDataAdapter(strSQL, cn)
daParam.Fill(Ds, "Param")
RowParam = Ds.Tables("Param").Rows.Find(stID)
If RowParam Is Nothing Then
intNumeroCde = 100
RowParam = Ds.Tables("Param").NewRow
RowParam("Code") = stID
RowParam("ncdeclient") = intNumeroCde
Ds.Tables("Param").Rows.Add(RowParam)
daParam.InsertCommand = ParamInsert(RowParam)
Else
NumeroCde = RowParam("ncdeclient")
RowParam.BeginEdit()
RowParam("ncdeclient") = intNumeroCde + 1
RowParam.EndEdit()
daParam.UpdateCommand = ParamUpdate()
End If
daParam.Update(Ds.Tables("Param"))
Private Function ParamUpdate() As SqlCommand
Dim cmd As SqlCommand
strSQL = "UPDATE A_PARAM SET NCDECLIENT = ? WHERE CODE = ? "
cmd = New SqlCommand(strSQL, cn)
cmd.Parameters.Add("ncdeclient", SqlDbType.Int, 0, "ncdeclient")
cmd.Parameters.Add("code", SqlDbType.VarChar, 50, "code")
Return cmd
End Function
I change my oledb namespace to sql namespace, and I have several problems
with the update command.
It worked fine with oledb but now, I drive me crazy.
And it happens for each of my update datatables.
By the way, I thank you for your help on my previous posts.
Stan
Here's a bit of my code :
strSQL = "Select code,ncdeclient FROM A_PARAM WHERE CODE='" &
stID + & "'"
daParam = New SqlDataAdapter(strSQL, cn)
daParam.Fill(Ds, "Param")
RowParam = Ds.Tables("Param").Rows.Find(stID)
If RowParam Is Nothing Then
intNumeroCde = 100
RowParam = Ds.Tables("Param").NewRow
RowParam("Code") = stID
RowParam("ncdeclient") = intNumeroCde
Ds.Tables("Param").Rows.Add(RowParam)
daParam.InsertCommand = ParamInsert(RowParam)
Else
NumeroCde = RowParam("ncdeclient")
RowParam.BeginEdit()
RowParam("ncdeclient") = intNumeroCde + 1
RowParam.EndEdit()
daParam.UpdateCommand = ParamUpdate()
End If
daParam.Update(Ds.Tables("Param"))
Private Function ParamUpdate() As SqlCommand
Dim cmd As SqlCommand
strSQL = "UPDATE A_PARAM SET NCDECLIENT = ? WHERE CODE = ? "
cmd = New SqlCommand(strSQL, cn)
cmd.Parameters.Add("ncdeclient", SqlDbType.Int, 0, "ncdeclient")
cmd.Parameters.Add("code", SqlDbType.VarChar, 50, "code")
Return cmd
End Function