Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > อยากให้มันใส่ ID อัตโนมัติ ที่เพิ่มค่าทีละ1ในดาต้าเบส แล้วก็เช็ค User กับ Email จากดาต้าเบสอะครับ



 

อยากให้มันใส่ ID อัตโนมัติ ที่เพิ่มค่าทีละ1ในดาต้าเบส แล้วก็เช็ค User กับ Email จากดาต้าเบสอะครับ

 



Topic : 025537



โพสกระทู้ ( 187 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์




using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;


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





protected void Page_Load(object sender, EventArgs e)
{



}



protected void txtPassword_TextChanged(object sender, EventArgs e)
{

}
protected void txtUser_TextChanged(object sender, EventArgs e)
{

}
protected void txtConfirmPassword_TextChanged(object sender, EventArgs e)
{

}
protected void txtFirstName_TextChanged(object sender, EventArgs e)
{

}
protected void txtLastName_TextChanged(object sender, EventArgs e)
{

}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{

}
protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{

}
protected void txtAge_TextChanged(object sender, EventArgs e)
{

}
protected void txtBirthDate_TextChanged(object sender, EventArgs e)
{

}
protected void txtAddress_TextChanged(object sender, EventArgs e)
{

}
protected void txtTel_TextChanged(object sender, EventArgs e)
{

}
protected void txtEmail_TextChanged(object sender, EventArgs e)
{

}
protected void txtConfirmEmail_TextChanged(object sender, EventArgs e)
{

}
protected void btnRegister_Click(object sender, EventArgs e)
{
//-------------------Insert SQL----------------------------
try
{
string connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connectionString))
{



string commandText = @"insert into Userdata (ID,nUser,Password,Firstname,Lastname,Sex,Age,Birthdate,Address,Tel,Email)
values ('2',@nUser,@Password,@Firstname,@Lastname,@sex,@Age,@Birthdate,@Address,@Tel,@Email)";



SqlCommand comm = new SqlCommand(commandText, conn);
conn.Open();







if (txtUser.Text.Length < 6)
{
string myscript = "alert ('กรุณาใส่ Username ระหว่าง 6 - 12 ตัวด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);

}

else if (txtUser.Text.Length > 12)
{
string myscript = "alert ('กรุณาใส่ Username ระหว่าง 6 - 12 ตัวด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);
}

else if (txtPassword.Text.Length < 6)
{
string myscript = "alert ('กรุณาใส่ Password ระหว่าง 6 - 12 ตัวด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);
}

else if (txtPassword.Text.Length > 12)
{
string myscript = "alert ('กรุณาใส่ Password ระหว่าง 6 - 12 ตัวด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);
}
else if (txtPassword.Text != txtConfirmPassword.Text)
{

Response.Write("<script>alert('กรุณากรอก Password ให้ตรงกันด้วยค่ะ ...')</script>");
}
else if (txtFirstName.Text.Length == 0)
{
string myscript = "alert ('กรุณาใส่ ชื่อ ด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);
}
else if (txtLastName.Text.Length == 0)
{
string myscript = "alert ('กรุณาใส่ นามสกุล ด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);
}

else if (txtAge.Text.Length == 0)
{
string myscript = "alert ('กรุณาใส่ อายุ ด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);
}
else if (txtBirthDate.Text.Length == 0)
{
string myscript = "alert ('กรุณาใส่ วันเกิด ด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);
}
else if (txtEmail.Text.Length == 0)
{
string myscript = "alert ('กรุณาใส่ อีเมล ด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);
}
else if (txtConfirmEmail.Text.Length == 0)
{
string myscript = "alert ('กรุณายืนยัน อีเมล ด้วยค่ะ...');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myscript, true);
}
else if (txtEmail.Text != txtConfirmEmail.Text)
{

Response.Write("<script>alert('กรุณากรอก Email ให้ตรงกันด้วยค่ะ ...')</script>");
}

else
{

comm.Parameters.Add("@nUser", SqlDbType.VarChar).Value = txtUser.Text.Trim();
comm.Parameters.Add("@Password", SqlDbType.VarChar).Value = txtPassword.Text.Trim();
comm.Parameters.Add("@Firstname", SqlDbType.VarChar).Value = txtFirstName.Text.Trim();
comm.Parameters.Add("@Lastname", SqlDbType.VarChar).Value = txtLastName.Text.Trim();
comm.Parameters.Add("@Sex", SqlDbType.VarChar).Value = RadioButtonList1.Text.Trim();
comm.Parameters.Add("@Age", SqlDbType.VarChar).Value = txtAge.Text.Trim();
comm.Parameters.Add("@Birthdate", SqlDbType.VarChar).Value = txtBirthDate.Text.Trim();
comm.Parameters.Add("@Email", SqlDbType.VarChar).Value = txtEmail.Text.Trim();
comm.Parameters.Add("@Address", SqlDbType.VarChar).Value = txtAddress.Text.Trim();
comm.Parameters.Add("@Tel", SqlDbType.VarChar).Value = txtTel.Text.Trim();
}


comm.ExecuteNonQuery();
conn.Close();


Response.Write("Register Succesfully..");
Response.Redirect("Succesfully.aspx");

}
}
catch (Exception ex)
{
Response.Write("");



}
}

//----------------------------------------------------------------------------------

protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{

}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{

}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{

}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{

}
}




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-03-17 19:04:14 By : nongbreesh View : 1648 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

กำหนดฟิวส์เป็นแบบ Auto Number น่ะครับ






Date : 2009-03-19 06:37:05 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยากให้มันใส่ ID อัตโนมัติ ที่เพิ่มค่าทีละ1ในดาต้าเบส แล้วก็เช็ค User กับ Email จากดาต้าเบสอะครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่