Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update dataset from TextBox

Status
Not open for further replies.

uuthanh

Programmer
Dec 27, 2002
9
US
Hi Experts,

I got these designed from Visual Studio .NET
- sqlconnection1
- sqlDataAdapter1
- DsProblemDesc1

my stored proc:

Create Procedure ProblemDesc_Sp
@ProblemID Integer
AS
SELECT ProblemID, ProblemDesc
FROM ProblemTbl
WHERE ProblemID = @ProblemID

on my webform1.aspx, I got a textbox txtProblemDesc and bound to the above dataset and it works fine.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myProblemID = Request.QueryString("ProblemID")
SqlDataAdapter1.SelectCommand.Parameters("@ProblemID").Value = CInt(myProblemID)
SqlDataAdapter1.Fill(DsProblemDesc1)
txtProblemDesc.text = DsProblemDesc1.Tables(0).Rows(0)("ProblemDesc")
End Sub

I would like my users be able to edit the "Problem Description" directly from the textbox and then click Save to save the new text into database. I tried this:

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
DsProblemDesc1.Tables(0).Rows(0)("ProblemDesc") = txtProblemDesc.text
SqlDataAdapter1.Update(DsProblemDesc1)
End Sub

but it does not update the database at all, still keeping the old "problem description".

Is there simple way to do this?

I tried both datagrid and UPDATE stored proc, but none of them seems works for me. Please help!

Thanks a whole bunch in advance.

 
You didn't accept changes and supply the update command.
Code:
        DsProblemDesc1.AcceptChanges()
        SqlDataAdapter1.UpdateCommand = New SqlCommand("UpdateProblemDesc_Sp")
        SqlDataAdapter1.UpdateCommand.CommandType = CommandType.StoredProcedure
        SqlDataAdapter1.Update(DsProblemDesc1)
Make sure you have an update procedure called "UpdateProblemDesc_Sp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top