[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

11/04/2009 at 06:31PM PST, ID: 24873312 | Points: 500
[x]
Attachment Details

Trouble with Profile proceedure

Asked by bodge-k in Programming for ASP.NET, C# Programming Language, Microsoft Visual C#.Net

Tags: Visual Studio C#

Could someone please give me an example of how to do this simple proceedure?
What I am trying to do is this.
My member "any member" logs in to my site. The member clicks on a link to create their profile.
There are just three simple text boxes where the user can input their stage name, first name, and last name.
What am I doing wrong?


See the aspx.cs attached
See the aspx page code below.

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <br />
<br />
    <asp:Label ID="StgNameLbl" runat="server" Text="Enter Your Stage Name:"></asp:Label>
    <asp:TextBox ID="StageName" runat="server"></asp:TextBox>
    <br />
<br />
    <asp:Label ID="FNLbl" runat="server" Text="First Name:"></asp:Label>
    <asp:TextBox ID="FirstName" runat="server"></asp:TextBox>
    <br />
<br />
    <asp:Label ID="Label2" runat="server" Text="Last Name:"></asp:Label>
    <asp:TextBox ID="LastName" runat="server" ></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />
</asp:Content>
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.AccessControl;
using System.Web.Security;
using System.Configuration;
using System.Data.SqlClient;
 
public partial class Models_CreateProfile : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        
 
    protected void Button1_Click(object sender, EventArgs e)
        {
        // Get the UserId of the logged in user 
        MembershipUser CurrentUser = Membership.GetUser(User.Identity.Name);
        
 
        //Get Profile Data Entered by user in TextBox
        String sn = StageName.Text;               
        String fn = FirstName.Text;
        String ln = LastName.Text;
 
        // Insert a new record into Profile
 
        // Get your Connection String from the web.config
 
        string connectionString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString; string insertSql = "INSERT INTO Profile(StageName,FirstName, LastName) VALUES(@StageName,@FirstName, @LastName)";
        
 
        using (SqlConnection myConnection = new SqlConnection(connectionString))
            {
 
            myConnection.Open();
            SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
 
            //myCommand.Parameters.AddWithValue("@UserId", UserId);
            myCommand.Parameters.AddWithValue("@StageName", sn);
            myCommand.Parameters.AddWithValue("@FirstName", fn);
            myCommand.Parameters.AddWithValue("@LastName", ln);
            myCommand.ExecuteNonQuery();
            myConnection.Close();
 
            }
        }
 
}
[+][-]11/17/09 03:56 AM, ID: 25838809

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_3_20080625