updating data in the backend

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sweatha
    New Member
    • Mar 2008
    • 44

    updating data in the backend

    Hi

    In my home page I have the login form & the link button named "Update Profile?". If I click that link button, then it redirects to the page which has the Profile Updation Process which includes all the profile details that the user registered during registration and the user can update the existing profile here. For that, in the profile updation page, I have given the coding as

    Imports System.Data
    Imports System.Data.Sql Client
    Partial Class Default2
    Inherits System.Web.UI.P age
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
    If Not Page.IsPostBack Then
    Dim con As SqlConnection
    Dim cmd As SqlCommand
    Dim str, str1 As String
    str = "user id=sa;password= cast;database=j sc;server=AUROR A-SERVER"
    con = New SqlConnection(s tr)
    Try
    con.Open()
    Catch
    End Try
    str1 = "select * from login"
    cmd = New SqlCommand(str1 , con)
    Dim dr1 As SqlDataReader
    dr1 = cmd.ExecuteRead er()
    While dr1.Read()
    txtLoginId2.Tex t = dr1.GetValue(0)
    txtPassword1.Te xt = dr1.GetValue(1)
    txtConfirmPassw ord.Text = dr1.GetValue(2)
    txtFirstName.Te xt = dr1.GetValue(3)
    txtLastName.Tex t = dr1.GetValue(4)
    txtAddress.Text = dr1.GetValue(5)
    txtAddress2.Tex t = dr1.GetValue(6)
    txtAddress3.Tex t = dr1.GetValue(7)
    txtCity.Text = dr1.GetValue(8)
    txtCountry.Text = dr1.GetValue(9)
    txtProvince.Tex t = dr1.GetValue(10 )
    txtPostalCode.T ext = dr1.GetValue(11 )
    txtPhone.Text = dr1.GetValue(12 )
    txtEmail1.Text = dr1.GetValue(13 )
    txtHow.Text = dr1.GetValue(14 )
    End While
    con.Close()
    End If
    End Sub



    Protected Sub btnUpdateProfil e_Click1(ByVal sender As Object, ByVal e As System.EventArg s) Handles btnRegister.Cli ck
    Dim con As SqlConnection
    Dim cmd As SqlCommand
    Dim str, str1 As String
    str = "user id=sa;password= cast;database=j sc;server=AUROR A-SERVER"
    con = New SqlConnection(s tr)
    Try
    con.Open()
    Catch
    End Try
    str1 = "update login set loginid='" & txtLoginId2.Tex t & "', password='" & txtPassword1.Te xt & "',confirmpassw ord='" & txtConfirmPassw ord.Text & "',firstnam e='" & txtFirstName.Te xt & "',lastname ='" & txtLastName.Tex t & "',address= '" & txtAddress.Text & "',address2 ='" & txtAddress2.Tex t & "',address3 ='" & txtAddress3.Tex t & "',city='" & txtCity.Text & "',country= '" & txtCountry.Text & "',province ='" & txtProvince.Tex t & "',postalco de=" & txtPostalCode.T ext & ",phone='" & txtPhone.Text & "',email='" & txtEmail1.Text & "',how='" & txtHow.Text & "'"
    cmd = New SqlCommand(str1 , con)
    cmd.ExecuteNonQ uery()
    con.Close()
    Response.Redire ct("Default3.as px")
    End Sub
    End Class

    But if I give the above coding, only the last record is getting displayed on the textbox. The thing is the profile should get displayed on the textboxes according to the loginid and password that the user has entered on the login page.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    is the profile getting updated ?

    Comment

    • sweatha
      New Member
      • Mar 2008
      • 44

      #3
      Originally posted by debasisdas
      is the profile getting updated ?
      Its getting updated. But the profile should get displayed on the textboxes according to the loginid and password that the user entered.

      Comment

      Working...