0
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???

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by sujimon
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.