Hi All
Could someone help me find what is wrong with the following piece of code?... for some reason it doesn't seem to do what it is supposed to do and update a record using the stored procedure... I have been looking at it for ages now but still cannot see anything wrong!..
Code:
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim recID As SqlParameter
Dim recTitle As SqlParameter
Dim UpdateTitle As TextBox = FormView1.FindControl("TitleTextBox")
MyConnection = New SqlConnection()
MyConnection.ConnectionString = _
ConfigurationManager.ConnectionStrings("myconnection").ConnectionString
MyCommand = New SqlCommand()
MyCommand.CommandText = "MY_UPDATE_SPROC"
MyCommand.CommandType = CommandType.StoredProcedure
MyCommand.Connection = MyConnection
recID = New SqlParameter()
recID.ParameterName = "@Rec_ID"
recID.SqlDbType = SqlDbType.Int
recID.Direction = ParameterDirection.Input
recID.Value = Request.QueryString("rec")
recTitle = New SqlParameter()
recTitle.ParameterName = "@rec_Title"
recTitle.SqlDbType = SqlDbType.VarChar
recTitle.Direction = ParameterDirection.Input
recTitle.Value = UpdateTitle.Text
MyCommand.Parameters.Add(recID)
MyCommand.Parameters.Add(recTitle)
MyCommand.Connection.Open()
myCommand.ExecuteNonQuery()
MyConnection.Dispose()
It is embedded within the code behind of an OnClick event.
Many thanks
Rit