|
|
|
สมัครสมาชิก asp.net vb2010 sql server2008 ให้มันแจ้งเตือนถ้า username กับ email มีผู้ใช้สมัครไปแล้ว |
|
|
|
|
|
|
|
บทความนี้ครับ
Code (VB.NET)
Sub btnSave_Click(sender As Object, e As EventArgs)
Dim intNumRows As Integer
strSQL = "SELECT COUNT(*) FROM customer WHERE CustomerID = '"& Me.txtCustomerID.Text &"' "
objCmd = New SqlCommand(strSQL, objConn)
intNumRows = objCmd.ExecuteScalar()
IF intNumRows > 0 Then
Me.pnlAdd.Visible = False
Me.lblStatus.Visible = True
Me.lblStatus.Text = "CustomerID already exist."
Else
strSQL = "INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) " & _
" VALUES " & _
" ('" & Me.txtCustomerID.Text & "','" & Me.txtName.Text & "','" & Me.txtEmail.Text & "', " & _
" '" & Me.txtCountryCode.Text & "','" & Me.txtBudget.Text & "','" & Me.txtUsed.Text & "')"
objCmd = New SqlCommand
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
Me.pnlAdd.Visible = False
Try
objCmd.ExecuteNonQuery()
Me.lblStatus.Text = "Record Inserted"
Me.lblStatus.Visible = True
Catch ex As Exception
Me.lblStatus.Visible = True
Me.lblStatus.Text = "Record can not insert Error ("& ex.Message &")"
End Try
End IF
End Sub
Go to : ASP.NET SQL Server Check Already Exists Add/Insert Record
|
|
|
|
|
Date :
2012-06-04 18:43:36 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่น่ารักจัง ขอบคุณมากๆๆนะค่ะ ได้ไม่ได้ยังไงเดี๋ยวหนูมาบอกค่ะ
|
|
|
|
|
Date :
2012-06-04 19:20:49 |
By :
Belletempo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|