Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2004, 01:22 AM
Authorized User
 
Join Date: Mar 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Record not updating

hey all

ok i have a datagrid and a hyperlink column EDIT thar directs the row selected to a form on an edit page.

when i chnage the values in the textboxes and click an edit button, i only get the old values from the textboxes and not the new changed values

how come?

pls help

What Comes Around Goes Around!
__________________
What Comes Around Goes Around!
 
Old March 24th, 2004, 01:41 AM
Authorized User
 
Join Date: Mar 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        IntAgent_id = Request.QueryString("id")
        AGentConn.Open()

        strSelect = "select * from Agent where ag_id=" & IntAgent_id

        Try
            Dim selectCommand As New SqlCommand(strSelect, AGentConn)

            selectReader = selectCommand.ExecuteReader()

            While selectReader.Read()
                idtb.Text = (selectReader("ag_id"))
                nametb.Text = (selectReader("ag_name"))
                add1tb.Text = (selectReader("ag_address1"))
                add2tb.Text = (selectReader("ag_address2"))
                add3tb.Text = (selectReader("ag_address3"))
                phone1tb.Text = (selectReader("ag_telephone1"))
                phone2tb.Text = (selectReader("ag_telephone2"))
                faxtb.Text = (selectReader("ag_fax1"))
                contacttb.Text = (selectReader("ag_contact"))
                mobiletb.Text = (selectReader("ag_mobile"))
                email1tb.Text = (selectReader("ag_email1"))
                urltb.Text = (selectReader("ag_url"))


            End While



        Catch ex As Exception

        End Try
        selectReader.Close()
        AGentConn.Close()


    End Sub

    Private Sub editAgentBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles editAgentBtn.Click

        strUpdate = "Update Agent Set ag_name=@ag_name, ag_address1=@ag_address1, ag_address2=@ag_address2, ag_address3=@ag_address3, ag_telephone1=@ag_telephone1, ag_telephone2=@ag_telephone2, ag_fax1=@ag_fax1, ag_contact=@ag_contact, ag_mobile=@ag_mobile, ag_email1=@ag_email1, ag_url=@ag_url where ag_id=" & IntAgent_id

        Dim strAg_Name As String = nametb.Text
        Dim strAg_add1 As String = add1tb.Text
        Dim strAg_add2 As String = add2tb.Text
        Dim strAg_add3 As String = add3tb.Text
        Dim strAg_phone1 As String = phone1tb.Text
        Dim strAg_phone2 As String = phone2tb.Text
        Dim strAg_fax As String = faxtb.Text
        Dim strAg_contact As String = contacttb.Text
        Dim strAg_mobile As String = mobiletb.Text
        Dim strAg_email As String = email1tb.Text
        Dim strAg_url As String = urltb.Text

        strUpdateCmd = New SqlCommand(strUpdate, AGentConn)
        strUpdateCmd.Parameters.Add("@ag_name", strAg_Name)
        strUpdateCmd.Parameters.Add("@ag_address1", strAg_add1)
        strUpdateCmd.Parameters.Add("@ag_address2", strAg_add2)
        strUpdateCmd.Parameters.Add("@ag_address3", strAg_add3)
        strUpdateCmd.Parameters.Add("@ag_telephone1", strAg_phone1)
        strUpdateCmd.Parameters.Add("@ag_telephone2", strAg_phone2)
        strUpdateCmd.Parameters.Add("@ag_fax1", strAg_fax)
        strUpdateCmd.Parameters.Add("@ag_contact", strAg_contact)
        strUpdateCmd.Parameters.Add("@ag_mobile", strAg_mobile)
        strUpdateCmd.Parameters.Add("@ag_email1", strAg_email)
        strUpdateCmd.Parameters.Add("@ag_url", strAg_url)
        AGentConn.Open()

        strUpdateCmd.ExecuteNonQuery()

        AGentConn.Close()
        'Response.Write(nametb.Text.ToString)
        Response.Redirect("agentMaster.aspx")
    End Sub
What Comes Around Goes Around!
 
Old March 24th, 2004, 11:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If Not IsPostBack Then
IntAgent_id = Request.QueryString("id")
        AGentConn.Open()

        strSelect = "select * from Agent where ag_id=" & IntAgent_id

        Try
            Dim selectCommand As New SqlCommand(strSelect, AGentConn)

            selectReader = selectCommand.ExecuteReader()

            While selectReader.Read()
                idtb.Text = (selectReader("ag_id"))
                nametb.Text = (selectReader("ag_name"))
                add1tb.Text = (selectReader("ag_address1"))
                add2tb.Text = (selectReader("ag_address2"))
                add3tb.Text = (selectReader("ag_address3"))
                phone1tb.Text = (selectReader("ag_telephone1"))
                phone2tb.Text = (selectReader("ag_telephone2"))
                faxtb.Text = (selectReader("ag_fax1"))
                contacttb.Text = (selectReader("ag_contact"))
                mobiletb.Text = (selectReader("ag_mobile"))
                email1tb.Text = (selectReader("ag_email1"))
                urltb.Text = (selectReader("ag_url"))


            End While



        Catch ex As Exception

        End Try
        selectReader.Close()
        AGentConn.Close()
End If
    End Sub


 
Old March 24th, 2004, 12:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Otherwise the page is doing what you're telling it to on the Page_Load... *refresh the text boxes with the data from the database without updating*.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating database record shrisangeeta Classic ASP Basics 4 February 28th, 2007 05:25 PM
Updating the record in database lwebzem ASP.NET 1.0 and 1.1 Basics 4 March 8th, 2006 09:40 AM
Updating the record in the database lwebzem ASP.NET 1.0 and 1.1 Basics 3 February 28th, 2006 07:57 AM
Updating first found record rtr1900 Classic ASP Databases 9 December 2nd, 2005 03:09 AM
updating record stoneman Access 1 July 5th, 2005 09:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.