|
|
|
อยากทราบการทำ confirm password ช่วยสอนหน่อยครับ C# |
|
|
|
|
|
|
|
จากโค๊ดผมอยากทราบว่าจะทำรูปแบบ confirm password ยังไงหรอครับ
Code (C#)
myConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\first\\โปรเจค\\Frist.accdb";
myConn.Open();
OleDbCommand mycommand = new OleDbCommand();
OleDbTransaction myTransaction;
OleDbParameter name = new OleDbParameter();
name.ParameterName = "@N";
name.OleDbType = OleDbType.Char;
name.Direction = ParameterDirection.Input;
name.Value = textBox1.Text;
OleDbParameter Sur = new OleDbParameter();
Sur.ParameterName = "@S";
Sur.OleDbType = OleDbType.Char;
Sur.Direction = ParameterDirection.Input;
Sur.Value = textBox2.Text;
OleDbParameter user = new OleDbParameter();
user.ParameterName = "@U";
user.OleDbType = OleDbType.Char;
user.Direction = ParameterDirection.Input;
user.Value = textBox5.Text;
OleDbParameter Pass = new OleDbParameter();
Pass.ParameterName = "@P";
Pass.OleDbType = OleDbType.Char;
Pass.Direction = ParameterDirection.Input;
Pass.Value = textBox6.Text;
OleDbParameter email = new OleDbParameter();
email.ParameterName = "@E";
email.OleDbType = OleDbType.Char;
email.Direction = ParameterDirection.Input;
email.Value = textBox3.Text;
OleDbParameter tel = new OleDbParameter();
tel.ParameterName = "@T";
tel.OleDbType = OleDbType.Char;
tel.Direction = ParameterDirection.Input;
tel.Value = textBox4.Text;
myTransaction = myConn.BeginTransaction();
mycommand.CommandText = "INSERT INTO [member]([M_name],[M_surname],[M_user],[M_pass],[M_email],[M_tel])VALUES(@N,@S,@U,@P,@E,@T)";
mycommand.CommandType = CommandType.Text;
mycommand.Transaction = myTransaction;
mycommand.Connection = myConn;
mycommand.Parameters.Add(name);
mycommand.Parameters.Add(Sur);
mycommand.Parameters.Add(user);
mycommand.Parameters.Add(Pass);
mycommand.Parameters.Add(email);
mycommand.Parameters.Add(tel);
mycommand.ExecuteNonQuery();
myTransaction.Commit();
this.Hide();
}
Tag : .NET, C#, C
|
ประวัติการแก้ไข 2012-10-22 14:23:37
|
|
|
|
|
Date :
2012-10-22 14:19:32 |
By :
white31969 |
View :
1317 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if else ใส่แบบนี้อะครับมันขึ้นว่ารหัสผ่านไม่ตรงกัน ใส่ไม่เหมือนก็ขึ้น ใส่เหมือนก็ขึ้น
Code (C#)
if (textBox6 == textBox7)
{
myConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\first\\โปรเจค\\Frist.accdb";
myConn.Open();
OleDbCommand mycommand = new OleDbCommand();
OleDbTransaction myTransaction;
OleDbParameter name = new OleDbParameter();
name.ParameterName = "@N";
name.OleDbType = OleDbType.Char;
name.Direction = ParameterDirection.Input;
name.Value = textBox1.Text;
OleDbParameter Sur = new OleDbParameter();
Sur.ParameterName = "@S";
Sur.OleDbType = OleDbType.Char;
Sur.Direction = ParameterDirection.Input;
Sur.Value = textBox2.Text;
OleDbParameter user = new OleDbParameter();
user.ParameterName = "@U";
user.OleDbType = OleDbType.Char;
user.Direction = ParameterDirection.Input;
user.Value = textBox5.Text;
OleDbParameter Pass = new OleDbParameter();
Pass.ParameterName = "@P";
Pass.OleDbType = OleDbType.Char;
Pass.Direction = ParameterDirection.Input;
Pass.Value = textBox6.Text;
OleDbParameter email = new OleDbParameter();
email.ParameterName = "@E";
email.OleDbType = OleDbType.Char;
email.Direction = ParameterDirection.Input;
email.Value = textBox3.Text;
OleDbParameter tel = new OleDbParameter();
tel.ParameterName = "@T";
tel.OleDbType = OleDbType.Char;
tel.Direction = ParameterDirection.Input;
tel.Value = textBox4.Text;
myTransaction = myConn.BeginTransaction();
mycommand.CommandText = "INSERT INTO [member]([M_name],[M_surname],[M_user],[M_pass],[M_email],[M_tel])VALUES(@N,@S,@U,@P,@E,@T)";
mycommand.CommandType = CommandType.Text;
mycommand.Transaction = myTransaction;
mycommand.Connection = myConn;
mycommand.Parameters.Add(name);
mycommand.Parameters.Add(Sur);
mycommand.Parameters.Add(user);
mycommand.Parameters.Add(Pass);
mycommand.Parameters.Add(email);
mycommand.Parameters.Add(tel);
mycommand.ExecuteNonQuery();
myTransaction.Commit();
this.Hide();
}
else
{
MessageBox.Show("รหัสผ่านไม่ตรงกัน");
}
|
|
|
|
|
Date :
2012-10-22 14:22:52 |
By :
white31969 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเปลี่ยนจาก (textBox6 == textBox7)
เป็น (textBox6.Text == textBox7.Text) มั้ยครับ
|
|
|
|
|
Date :
2012-10-22 15:02:46 |
By :
phaizz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับแหะๆๆขอบคุณมากครับพิมผิดอิอิ พิมพ์เป็น .text
|
ประวัติการแก้ไข 2012-10-22 15:50:26
|
|
|
|
Date :
2012-10-22 15:36:34 |
By :
white31969 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยหน่อยนะครับ Y_Y โปรเจคจบ
พอกดรอบแรก Msbox ขึ้นปกติ ("กรุณากรอกข้อมูลให้ครบ"); แต่พอรอบที่2มัน Error ตรงการเชื่อมมต่อฐานข้อมููลอะครับ
Code
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "")
{
MessageBox.Show("กรุณากรอกข้อมูลให้ครบ");
}
if (textBox6.Text == textBox7.Text)
{
myConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\first\\โปรเจค\\Frist.accdb";
myConn.Open();
OleDbCommand mycommand = new OleDbCommand();
OleDbTransaction myTransaction;
OleDbParameter name = new OleDbParameter();
name.ParameterName = "@N";
name.OleDbType = OleDbType.Char;
name.Direction = ParameterDirection.Input;
name.Value = textBox1.Text;
OleDbParameter Sur = new OleDbParameter();
Sur.ParameterName = "@S";
Sur.OleDbType = OleDbType.Char;
Sur.Direction = ParameterDirection.Input;
Sur.Value = textBox2.Text;
OleDbParameter user = new OleDbParameter();
user.ParameterName = "@U";
user.OleDbType = OleDbType.Char;
user.Direction = ParameterDirection.Input;
user.Value = textBox5.Text;
OleDbParameter Pass = new OleDbParameter();
Pass.ParameterName = "@P";
Pass.OleDbType = OleDbType.Char;
Pass.Direction = ParameterDirection.Input;
Pass.Value = textBox6.Text;
OleDbParameter email = new OleDbParameter();
email.ParameterName = "@E";
email.OleDbType = OleDbType.Char;
email.Direction = ParameterDirection.Input;
email.Value = textBox3.Text;
OleDbParameter tel = new OleDbParameter();
tel.ParameterName = "@T";
tel.OleDbType = OleDbType.Char;
tel.Direction = ParameterDirection.Input;
tel.Value = textBox4.Text;
myTransaction = myConn.BeginTransaction();
mycommand.CommandText = "INSERT INTO [member]([M_name],[M_surname],[M_user],[M_pass],[M_email],[M_tel])VALUES(@N,@S,@U,@P,@E,@T)";
mycommand.CommandType = CommandType.Text;
mycommand.Transaction = myTransaction;
mycommand.Connection = myConn;
mycommand.Parameters.Add(name);
mycommand.Parameters.Add(Sur);
mycommand.Parameters.Add(user);
mycommand.Parameters.Add(Pass);
mycommand.Parameters.Add(email);
mycommand.Parameters.Add(tel);
mycommand.ExecuteNonQuery();
myTransaction.Commit();
}
else
{
MessageBox.Show("รหัสผ่านไม่ตรงกัน");
}
}
|
ประวัติการแก้ไข 2012-10-22 16:27:53 2012-10-22 16:29:07
|
|
|
|
Date :
2012-10-22 16:27:01 |
By :
white31969 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|