ขอ Code ตรวจสอบข้อมูลก่อนการเพิ่มลงในฐานข้อมูลด้วยครับ
Code (VB.NET)
Dim intNumRows As Integer
strSQL = "SELECT COUNT(*) FROM customer WHERE CustomerID = '"& Me.txtCustomerID.Text &"' "
objCmd = New OleDbCommand(strSQL, objConn)
intNumRows = objCmd.ExecuteScalar()
IF intNumRows > 0 Then
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 OleDbCommand
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
objCmd.ExecuteNonQuery()
ASP.NET & Access
Date :
2009-01-06 07:11:49
By :
webmaster
Load balance : Server 05