01.
Sub
btnSave_Click(sender
As
Object
, e
As
EventArgs)
02.
Dim
objConn
As
New
SqlConnection
03.
Dim
objCmd
As
New
SqlCommand
04.
Dim
strConnString,strSQL
As
String
05.
06.
strConnString =
"Server=localhost;UID=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
07.
08.
strSQL =
"INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) "
& _
09.
" VALUES "
& _
10.
" ('"
&
Me
.txtCustomerID.Text &
"','"
&
Me
.txtName.Text &
"','"
&
Me
.txtEmail.Text &
"', "
& _
11.
" '"
&
Me
.txtCountryCode.Text &
"','"
&
Me
.txtBudget.Text &
"','"
&
Me
.txtUsed.Text &
"')"
12.
objConn.ConnectionString = strConnString
13.
objConn.Open()
14.
With
objCmd
15.
.Connection = objConn
16.
.CommandText = strSQL
17.
.CommandType = CommandType.Text
18.
End
With
19.
20.
Me
.pnlAdd.Visible =
False
21.
22.
Try
23.
objCmd.ExecuteNonQuery()
24.
Me
.lblStatus.Text =
"Record Inserted"
25.
Me
.lblStatus.Visible =
True
26.
Catch
ex
As
Exception
27.
Me
.lblStatus.Visible =
True
28.
Me
.lblStatus.Text =
"Record can not insert Error ("
& ex.Message &
")"
29.
End
Try
30.
31.
objConn.Close()
32.
objConn =
Nothing
33.
34.
End
Sub