Click here to Skip to main content
15,880,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: Enumerate through the values of a enum Pin
Sentenryu10-Oct-12 8:55
Sentenryu10-Oct-12 8:55 
GeneralRe: Enumerate through the values of a enum Pin
Mr. Tapan Kumar10-Oct-12 9:47
Mr. Tapan Kumar10-Oct-12 9:47 
GeneralRe: Enumerate through the values of a enum Pin
J4amieC10-Oct-12 21:26
J4amieC10-Oct-12 21:26 
GeneralRe: Enumerate through the values of a enum Pin
J4amieC10-Oct-12 21:25
J4amieC10-Oct-12 21:25 
GeneralRe: Enumerate through the values of a enum Pin
Dave Kreskowiak10-Oct-12 23:52
mveDave Kreskowiak10-Oct-12 23:52 
AnswerRe: Enumerate through the values of a enum Pin
J4amieC10-Oct-12 21:20
J4amieC10-Oct-12 21:20 
GeneralRe: Enumerate through the values of a enum Pin
Sentenryu11-Oct-12 0:07
Sentenryu11-Oct-12 0:07 
QuestionProviderUserKey error Pin
saiprakash031510-Oct-12 6:15
saiprakash031510-Oct-12 6:15 
Hi i'm working out my registration using a three tiered architecture and i'm trying to send the random userid which i got from registering in the aspx page to my custom table which i created. Here is the error i get:
Error 1 'DataClass.ConnectionClass' does not contain a definition for 'ProviderUserKey' and no extension method 'ProviderUserKey' accepting a first argument of type 'DataClass.ConnectionClass' could be found (are you missing a using directive or an assembly reference? Does anyone know how to correct it

here is my presentation layer or the UI layer
C#
/* Program Created by
 * Name: Sai Ayilavarapu
 * Form Description: To create and validate registration form
 * Things thats are mandatory: username, email, password, security question, security answer
 */

using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.ApplicationServices;
using System.Data;
using System.Data.SqlClient;
using DataClass;


public partial class Account_Register : System.Web.UI.Page
{

    ConnectionClass newobj = new ConnectionClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        //RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
    }
  
    protected void CreateUserButton_Click(object sender, EventArgs e)
    {
        
        string F_Name = txtFirstName.Text;
        string L_Name = txtLastName.Text;
        string Address = txtAddress.Text;
        string City = txtCity.Text;
        string State = txtState.Text;
        string Zip = txtZipCode.Text;
        string DOB = txtDOB.Text;
        string Phone = txtPhone.Text;
        string email = txtEmail.Text;
        string User_Name = txtUserName.Text;
        string Password = txtPassword.Text;
        string PasswordQuestion = txtPasswordQuestion.Text;
        string PasswordAnswer = txtPasswordAnswer.Text;


        MembershipCreateStatus createStatus;
        MembershipUser newUser = Membership.CreateUser(txtUserName.Text, txtPassword.Text, txtEmail.Text, txtPasswordQuestion.Text, txtPasswordAnswer.Text, true, out createStatus);
        switch (createStatus)
        {
            case MembershipCreateStatus.Success:
                string UserId = newUser.ProviderUserKey.ToString(); //create provider key?
                lblCreateAccount.Text = "The user account was successfully created!";
                break;
            case MembershipCreateStatus.DuplicateUserName:
                lblCreateAccount.Text = "There already exists a user with this username.";
                break;

            case MembershipCreateStatus.DuplicateEmail:
                lblCreateAccount.Text = "There already exists a user with this email address.";
                break;
            case MembershipCreateStatus.InvalidEmail:
                lblCreateAccount.Text = "There email address you provided in invalid.";
                break;
            case MembershipCreateStatus.InvalidAnswer:
                lblCreateAccount.Text = "There security answer was invalid.";
                break;
            case MembershipCreateStatus.InvalidPassword:
                lblCreateAccount.Text = "The password you provided is invalid. It must be seven characters long and have at least one non-alphanumeric character.";

                break;
            default:
                lblCreateAccount.Text = "There was an unknown error; the user account was NOT created.";
                break;

                
        }
        string userid;
        if (newUser != null)
                {
                        
             userid = newobj.ProviderUserKey.ToString(); // it shows the error here
             newobj.Insert(userid, F_Name, L_Name, Address, City, State, Zip, DOB, Phone,
              email, User_Name, Password, PasswordQuestion, PasswordAnswer);

                }


 
    }

}


Here is my Data Layer
C#
using System;

using System.Data;

using System.Configuration;
using System.Collections.Specialized;
using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

namespace DataClass
{
    public class ConnectionClass
    {
        string connStr = ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ToString();
        public ConnectionClass()
        {  
            // Add Constructor Logic
            
        }
        
        public int Insert (string U_ID, string F_Name, string L_Name, string Address, string City, string State, string Zip, string DOB, string Phone,
            string email, string User_Name, string Password, string PasswordQuestion, string PasswordAnswer)
        {

            SqlConnection con = new SqlConnection(connStr);
            con.Open();
            SqlCommand cmd = new SqlCommand("user_membership", con);
            cmd.CommandType = CommandType.StoredProcedure;
            try {
            
            cmd.Parameters.Add("@UserId", SqlDbType.UniqueIdentifier).Value = new Guid(U_ID);
            cmd.Parameters.AddWithValue("@F_Name", F_Name);
            cmd.Parameters.AddWithValue("@L_Name", L_Name);
            cmd.Parameters.AddWithValue("@Address", Address);
            cmd.Parameters.AddWithValue("@City", City);
            cmd.Parameters.AddWithValue("@State", State);
            cmd.Parameters.AddWithValue("@Zip", Zip);
            cmd.Parameters.AddWithValue("@DOB", DOB);
            cmd.Parameters.AddWithValue("@Phone", Phone);
            cmd.Parameters.AddWithValue("@email", email);
            cmd.Parameters.AddWithValue("@User_Name", User_Name);
            cmd.Parameters.AddWithValue("@Password", Password);
            cmd.Parameters.AddWithValue("@PasswordQuestion", PasswordQuestion);
            cmd.Parameters.AddWithValue("@PasswordAnswer", PasswordAnswer);
            return cmd.ExecuteNonQuery();

            }
            catch { throw; }
            finally 
            {
               
                con.Dispose();
                con.Close();
                cmd.Dispose();
            }
            

        }

        public DataTable Load(string F_Name, string L_Name, string Address, string City, string State, string Zip, string DOB, string Phone,
            string email, string User_Name, string Password, string PasswordQuestion, string PasswordAnswer)
        {
            SqlConnection conn = new SqlConnection(connStr);

            SqlCommand cmd = new SqlCommand("user_membership", conn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;

            DataSet ds = new DataSet();
            try
            {
                // da.GetFillParameters();
                cmd.Parameters.AddWithValue("@F_Name", F_Name);
                cmd.Parameters.AddWithValue("@L_Name", L_Name);
                cmd.Parameters.AddWithValue("@Address", Address);
                cmd.Parameters.AddWithValue("@City", City);
                cmd.Parameters.AddWithValue("@State", State);
                cmd.Parameters.AddWithValue("@Zip", Zip);
                cmd.Parameters.AddWithValue("@DOB", DOB);
                cmd.Parameters.AddWithValue("@Phone", Phone);
                cmd.Parameters.AddWithValue("@email", email);
                cmd.Parameters.AddWithValue("@User_Name", User_Name);
                cmd.Parameters.AddWithValue("@Password", Password);
                cmd.Parameters.AddWithValue("@PasswordQuestion", PasswordQuestion);
                cmd.Parameters.AddWithValue("@PasswordAnswer", PasswordAnswer);
                da.Fill(ds);
                return ds.Tables[0];
            }
            catch
            {
                throw;
            }
            finally
            {
                ds.Dispose();
                da.Dispose();
                conn.Close();

                conn.Dispose();
            }
        }

    }
}

AnswerRe: ProviderUserKey error Pin
OriginalGriff10-Oct-12 8:36
mveOriginalGriff10-Oct-12 8:36 
GeneralRe: ProviderUserKey error Pin
saiprakash031510-Oct-12 14:14
saiprakash031510-Oct-12 14:14 
QuestionC# Pin
Jaleel Ahmed10-Oct-12 6:11
Jaleel Ahmed10-Oct-12 6:11 
AnswerRe: C# Pin
Paul Conrad10-Oct-12 7:31
professionalPaul Conrad10-Oct-12 7:31 
AnswerRe: C# Pin
Abhinav S10-Oct-12 16:08
Abhinav S10-Oct-12 16:08 
AnswerRe: C# Pin
KiranKumar Roy14-Oct-12 1:36
KiranKumar Roy14-Oct-12 1:36 
QuestionProgressive tax calculator in C# Pin
cyberhopper10-Oct-12 2:26
professionalcyberhopper10-Oct-12 2:26 
AnswerRe: Progressive tax calculator in C# Pin
Pete O'Hanlon10-Oct-12 3:05
mvePete O'Hanlon10-Oct-12 3:05 
GeneralRe: Progressive tax calculator in C# Pin
Paul Conrad10-Oct-12 7:33
professionalPaul Conrad10-Oct-12 7:33 
QuestionC# obtain return code from a proxy Pin
dcof10-Oct-12 2:23
dcof10-Oct-12 2:23 
AnswerRe: C# obtain return code from a proxy Pin
dojohansen10-Oct-12 3:06
dojohansen10-Oct-12 3:06 
GeneralRe: C# obtain return code from a proxy Pin
Pete O'Hanlon10-Oct-12 3:08
mvePete O'Hanlon10-Oct-12 3:08 
GeneralRe: C# obtain return code from a proxy Pin
dojohansen10-Oct-12 5:52
dojohansen10-Oct-12 5:52 
GeneralRe: C# obtain return code from a proxy Pin
dcof10-Oct-12 16:00
dcof10-Oct-12 16:00 
GeneralRe: C# obtain return code from a proxy Pin
dojohansen10-Oct-12 23:33
dojohansen10-Oct-12 23:33 
QuestionRender Excel document to word document using C#.net Pin
Ullas_Joseph9-Oct-12 22:35
Ullas_Joseph9-Oct-12 22:35 
AnswerRe: Render Excel document to word document using C#.net Pin
Marco Bertschi12-Oct-12 5:03
protectorMarco Bertschi12-Oct-12 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.