Ahh you want to call the code from another page? Then you need to do the following things on the site where the login control is:
Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As EventArgs)
response.redirect(String.Format("page2.aspx?user={0}",Login1.Username));
End sub
On the other page to the following:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
If Request.Querystring is nothing then
exit sub
end if
Dim yourUser As MembershipUser = Membership.GetUser(Request.Querystring("user"), True)
Dim userGuid As System.Guid = DirectCast(yourUser.ProviderUserKey, Guid)
Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("YourConnectionstringFromWebConfig").ConnectionString)
Dim cmd As New SqlCommand("Insert into table1 (Id,product) VALUES (@Id, @product)", conn) 'you should use sproc instead
cmd.Parameters.AddWithValue("@Id", userGuid)
cmd.Parameters.AddWithValue("@product", "...") 'your value
Try
conn.Open()
Dim rows As Int32 = cmd.ExecuteNonQuery()
conn.Close()
Trace.Write(String.Format("You have {0} rows inserted successfully!", rows.ToString()))
Catch sex As SqlException
Throw sex
Finally
If conn.State <> ConnectionState.Closed Then
conn.Close()
End If
End Try
End Sub
Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.