HI,
I'm creating an update form for update a records within a db.
The update routine is working if I hard code value into it.
The problem is that the form values are not being passed into the parameters.
Here is the code:
Here is the form:Code:Sub UpdateRec(Source as Object, E as EventArgs) dim dsn As String = ConfigurationSettings.AppSettings("SystemConnectionNew") dim objConn as New SqlConnection(dsn) Dim UpdateCommand As SqlCommand = New SqlCommand() UpdateCommand.Connection = objConn Dim sql As String sql = "UPDATE tbl_ACCO_EU_Contacts SET Title=@Title WHERE EndUserID=@EndUserID" UpdateCommand.CommandText = sql UpdateCommand.Parameters.Add(New SqlParameter("@Title", textTitle.Text)) UpdateCommand.Parameters.Add("@EndUserID", SqlDbType.Int).Value = 13 Try objConn.Open() UpdateCommand.ExecuteNonQuery() Catch ex As Exception response.Write(ex.ToString()) Finally objConn.Close() End Try 'response.Redirect("record_srch.aspx") End sub
Code:<form runat="server" name="selform"> <ol> <li > <label for="textTitle">Title:</label> <asp:TextBox ID="textTitle" runat="server" /> </li> <asp:TextBox Visible="false" ID="textEndUserID" runat="server" /> <li> <asp:Button ID="btnUpdate" Text="Update Record" Enabled="false" OnClick="UpdateRec" runat="server" /></li> </ul> </ol> </form>
Any help would be great.
Adz




Bookmarks