Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

       


        Dim conn As New SqlConnection
        Dim cmd As SqlCommand
        Dim dp As New SqlDataAdapter
        Dim ds As New DataSet
        Dim i As Integer
        Dim str As String = "UPDATE aspnet_Membership  SET aspnet_Membership.Email='" & Email.Text & "' WHERE UserId='" & Session("id") & "'"
        conn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.mdf;Integrated Security=True;User Instance=True")
        conn.Open()
        cmd = New SqlCommand()
        cmd.CommandType = CommandType.Text
        cmd.CommandText = str
        cmd.Connection = conn
        i = cmd.ExecuteNonQuery()
        MsgBox(Session("id"))


        Session("id") = Session("id")
        MsgBox(Session("id") + "after session")
        MsgBox(i)

        Dim userName As String = User.Identity.Name

        Dim usr As MembershipUser = Membership.GetUser(userName)
        'Email.Text = usr.Email
        Email.Text = usr.Email


    End Sub

in this code when i pring value of i variable its value is 1
but there is no cahnge in database .....
what is the error???

thanks ...actually connection is okk. when i update table without where condition ,query is running but with where condition error comes- multi part attribute can not b bound.

thanks ...actually connection is okk. when i update table without where condition ,query is running but with where condition error comes- multi part attribute can not b bound.

Try changing aspnet_membership.Email to email

OR

try changing userid in the where clause to aspnet_membership.userid.

OR even better would be like

update aspnet_membership a SET a.Email='" & Email.Text & "' WHERE a.UserId='" & Session("id") & "'"

And let me know what is the outcome.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.