01.
Dim
intNumRows
As
Integer
02.
strSQL =
"SELECT COUNT(*) FROM customer WHERE CustomerID = '"
&
Me
.txtCustomerID.Text &
"' "
03.
objCmd =
New
OleDbCommand(strSQL, objConn)
04.
intNumRows = objCmd.ExecuteScalar()
05.
06.
IF intNumRows > 0
Then
07.
Me
.pnlAdd.Visible =
False
08.
Me
.lblStatus.Visible =
True
09.
Me
.lblStatus.Text =
"CustomerID already exist."
10.
Else
11.
strSQL =
"INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) "
& _
12.
" VALUES "
& _
13.
" ('"
&
Me
.txtCustomerID.Text &
"','"
&
Me
.txtName.Text &
"','"
&
Me
.txtEmail.Text &
"', "
& _
14.
" '"
&
Me
.txtCountryCode.Text &
"','"
&
Me
.txtBudget.Text &
"','"
&
Me
.txtUsed.Text &
"')"
15.
16.
objCmd =
New
OleDbCommand
17.
With
objCmd
18.
.Connection = objConn
19.
.CommandText = strSQL
20.
.CommandType = CommandType.Text
21.
End
With
22.
23.
Me
.pnlAdd.Visible =
False
24.
Try
25.
objCmd.ExecuteNonQuery()
26.
Me
.lblStatus.Text =
"Record Inserted"
27.
Me
.lblStatus.Visible =
True
28.
Catch
ex
As
Exception
29.
Me
.lblStatus.Visible =
True
30.
Me
.lblStatus.Text =
"Record can not insert Error ("
& ex.Message &
")"
31.
End
Try
32.
End
IF