제목 : 31.3.1. 회원 가입 페이지 : ~/Register.ascx.cs
글번호:
|
|
192
|
작성자:
|
|
레드플러스
|
작성일:
|
|
2007/06/22 오후 6:24:00
|
조회수:
|
|
6049
|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;//
public partial class RegisterControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnRegister_Click(object sender, EventArgs e)
{
SqlConnection objCon = new SqlConnection();
objCon.ConnectionString =
ConfigurationManager.ConnectionStrings[
"ConnectionString"].ConnectionString;
objCon.Open();
SqlCommand objCmd = new SqlCommand();
objCmd.Connection = objCon;
objCmd.CommandText = "AddUser";
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.AddWithValue("@DomainID", txtDomainID.Text);
objCmd.Parameters.AddWithValue("@Name", txtName.Text);
objCmd.Parameters.AddWithValue("@Description", txtDescription.Text);
objCmd.Parameters.AddWithValue("@Password", txtPassword.Text);
objCmd.Parameters.AddWithValue("@Email", txtEmail.Text);
//[!] 반환형 매개변수 지정
objCmd.Parameters.Add("@UID", SqlDbType.Int);
objCmd.Parameters["@UID"].Direction =
ParameterDirection.Output;
int result = objCmd.ExecuteNonQuery();
objCon.Close();
if (result > 0)
{
Response.Redirect("~/Default.aspx"); // 메인으로 이동
}
else
{
lblError.Text = "이미 가입된 아이디입니다.";
}
}
}