I have an application that during a certain part a slope value is calculated and I want it to update the database with that value, however, the update is not happening. Here is the stored procedure:
Here is the function use to update located in a class:
Here is the function call:
Please help. Thanks
VB.NET:
ALTER PROCEDURE dbo.spUpdateSlope
(
@unitID int,
@slope decimal (18,6)
)
AS
UPDATE tblUnit
set slope = @slope,
dateModified = GETDATE()
WHERE unitID = @unitID
RETURN
Here is the function use to update located in a class:
VB.NET:
Public Function UpdateSlope(ByVal unitID As Integer, ByVal slope As Decimal)
Dim cnString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NucChem.MDF;" & _
"Integrated Security=True;Connect Timeout=30;User Instance=True"
Dim con As New SqlConnection(cnString)
Dim cmd As New SqlCommand("spUpdateSlope", con)
'Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
Dim recAffected As Integer
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "spUpdateSlope"
cmd.Parameters.AddWithValue("@unitID", unitID)
cmd.Parameters.AddWithValue("@slope", slope)
Try
If con.State <> ConnectionState.Open Then
con.Open()
End If
recAffected = cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End Function
Here is the function call:
VB.NET:
clsLith.UpdateSlope(unitID, slope)
Please help. Thanks
Last edited by a moderator: