 |
|
คือผมกำลังทำระบบ สมัครสมาชิกอยู่ แล้วการสมัครสมาชิกผมเขียนได้สำเร็จแล้วติดตรง ต้อง insert login
โดยที่ insert login นั้นจำเป็นต้องใช้ UserNum ใน table ที่ใช้ insert ข้อมูลไอดี
เหมือนกับว่า insert ID PW to UserInfo
แล้ว UserInfo จะมี UserNum ที่เปลี่ยนแปลงไม่ได้
ซึ่งผมอยากให้มีคำสั่งที่ Read ID ที่พิมเสร็จจาก textbox แล้วให้มันดึง textbox.text ไปเชคใน UserInfo
แล้วให้ดึง UserNum ใน Row ที่มี fdUID ที่ตรงกับ textbox.text ไปใช้ในการ insert
ที่ผมหามาคำสั่ง reader มัน reader ทั้ง table เลยผมพยายามหาที่มันดึงจาก textbox ไปหาไม่เจอเลยครับ
อันนี้เป็น Code insert ที่ผมทำไว้
Code (VB.NET)
Dim connection As New SqlConnection
Dim command As New SqlCommand
Dim command2 As New SqlCommand
connection.ConnectionString = "Server=XXXX;UID=sa;PASSWORD=XXXXX;Database=XXXXX;Max Pool Size=400;Connect Timeout=600;"
connection.Open()
command2.Connection = connection
command2.CommandType = CommandType.Text
command2.CommandText = "INSERT INTO UserInfo (fdUID,UserPass,UserEmail,UserPass2,fdAuthUserNum) VALUES ('" + Form2.TextBoxX1.Text + "','" + Form2.TextBoxX2.Text + "','" + Form2.TextBoxX3.Text + "','" + Form2.TextBoxX4.Text + "','" + Form2.TextBoxX5.Text + "')"
Try
If (Conversions.ToInteger(command2.ExecuteNonQuery) > 0) Then
Interaction.MsgBox("You account have been registered.", MsgBoxStyle.Information, "FunZ")
Else
Interaction.MsgBox("Register failed.", MsgBoxStyle.Critical, "Error 108 !")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
connection.Close()
connection = Nothing
Tag : Ms SQL Server 2008, VB.NET
|
|
 |
 |
 |
 |
Date :
2013-01-27 01:14:00 |
By :
alfan123 |
View :
826 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |