bftarane
شنبه 09 مهر 1390, 16:42 عصر
سلام.
از کنترل CreateUserWizard خود asp.net
استفاده نکردم و می خوام صفحه ثبت نام را خودم درست کنم.
برای این کار به جدول aspnet_Users خود asp.net دو تا فیلد اضافه کردم برای ذخیره کردن نام و نام خانوادگی کاربر.
در رویداد کلیک دکمه ثبت نام کدهای زیر را نوشته ام
SqlConnection myconnection = new SqlConnection(WebConfigurationManager.ConnectionSt rings["LocalSqlServer"].ConnectionString);
string mycommandtext = "Insert into aspnet_Users (UserId,ApplicationId,UserName,Name,Family) values (@UserId,@ApplicationId,@UserName,@Name,@Family)" +
"Insert into aspnet_Membeership (UserId,ApplicationId,PasswordQuestion,PasswordAns wer,Email,Password) values (@UserId,@ApplicationId,@Password,@PasswordQuestio n,@PasswordAnswer,@Email)";
SqlCommand mycommand = new SqlCommand(mycommandtext, myconnection);
mycommand.Parameters.AddWithValue("@ApplicationId",........);
mycommand.Parameters.AddWithValue("@UserId",........);
mycommand.Parameters.AddWithValue("@UserName", txtUserName.Text);
mycommand.Parameters.AddWithValue("@Name", txtname.Text);
mycommand.Parameters.AddWithValue("@Family", txtfamily.Text);
mycommand.Parameters.AddWithValue("@Password", txtPassword.Text);
mycommand.Parameters.AddWithValue("@PasswordQuestion", DropDownList1.SelectedItem.Value);
mycommand.Parameters.AddWithValue("@PasswordAnswer", txtanswer.Text);
mycommand.Parameters.AddWithValue("@Email", txtEmail.Text);
myconnection.Open();
mycommand.ExecuteNonQuery();
myconnection.Close();
در واقع من جدول جدیدی استفاده نکردم و دارم از همان جداول asp.net استفاده می کنم.
می دونید که ApplicationId و UserId دارای DataType uniqueidentifier هستند.
حال مشکل من اینه که جای اون نقطه چینها چی باید بنویسم که وقتی کاربر دکمه ثبت نام را کلیک می کنه دو فلید UserId و ApplicatinId خود به خود مقدار بگیرند؟
ممنون
از کنترل CreateUserWizard خود asp.net
استفاده نکردم و می خوام صفحه ثبت نام را خودم درست کنم.
برای این کار به جدول aspnet_Users خود asp.net دو تا فیلد اضافه کردم برای ذخیره کردن نام و نام خانوادگی کاربر.
در رویداد کلیک دکمه ثبت نام کدهای زیر را نوشته ام
SqlConnection myconnection = new SqlConnection(WebConfigurationManager.ConnectionSt rings["LocalSqlServer"].ConnectionString);
string mycommandtext = "Insert into aspnet_Users (UserId,ApplicationId,UserName,Name,Family) values (@UserId,@ApplicationId,@UserName,@Name,@Family)" +
"Insert into aspnet_Membeership (UserId,ApplicationId,PasswordQuestion,PasswordAns wer,Email,Password) values (@UserId,@ApplicationId,@Password,@PasswordQuestio n,@PasswordAnswer,@Email)";
SqlCommand mycommand = new SqlCommand(mycommandtext, myconnection);
mycommand.Parameters.AddWithValue("@ApplicationId",........);
mycommand.Parameters.AddWithValue("@UserId",........);
mycommand.Parameters.AddWithValue("@UserName", txtUserName.Text);
mycommand.Parameters.AddWithValue("@Name", txtname.Text);
mycommand.Parameters.AddWithValue("@Family", txtfamily.Text);
mycommand.Parameters.AddWithValue("@Password", txtPassword.Text);
mycommand.Parameters.AddWithValue("@PasswordQuestion", DropDownList1.SelectedItem.Value);
mycommand.Parameters.AddWithValue("@PasswordAnswer", txtanswer.Text);
mycommand.Parameters.AddWithValue("@Email", txtEmail.Text);
myconnection.Open();
mycommand.ExecuteNonQuery();
myconnection.Close();
در واقع من جدول جدیدی استفاده نکردم و دارم از همان جداول asp.net استفاده می کنم.
می دونید که ApplicationId و UserId دارای DataType uniqueidentifier هستند.
حال مشکل من اینه که جای اون نقطه چینها چی باید بنویسم که وقتی کاربر دکمه ثبت نام را کلیک می کنه دو فلید UserId و ApplicatinId خود به خود مقدار بگیرند؟
ممنون