Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 24th, 2004, 01:22 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
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!
  #2 (permalink)  
Old March 24th, 2004, 01:41 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
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!
  #3 (permalink)  
Old March 24th, 2004, 11:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
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


  #4 (permalink)  
Old March 24th, 2004, 12:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
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*.

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 10:12 AM



All times are GMT -4. The time now is 05:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.