01.
Imports
System.Data.SqlClient
02.
Public
Class
Form1
03.
Private
Sub
Form1_Load(sender
As
System.
Object
, e
As
System.EventArgs)
Handles
MyBase
.Load
04.
05.
End
Sub
06.
Private
Sub
Button1_Click(sender
As
System.
Object
, e
As
System.EventArgs)
Handles
Button1.Click
07.
08.
09.
10.
11.
Dim
strValues
As
String
=
""
12.
For
i
As
Integer
= 0
To
3
13.
strValues &=
"("
&
"'StringValue'"
&
"12.00"
&
If
(i < 3,
"), "
,
")"
)
14.
Next
15.
16.
Using cn
As
New
SqlConnection(
"Data Source=YourPCName;Initial Catalog=YourDatabaseName;User ID=sa;Password=1234"
)
17.
cn.Open()
18.
Using ts
As
SqlTransaction = cn.BeginTransaction()
19.
Try
20.
Using cmd
As
New
SqlCommand(
"INSERT INTO YourTableName VALUES "
& strValues, cn)
21.
cmd.Transaction = ts
22.
cmd.ExecuteNonQuery()
23.
ts.Commit()
24.
End
Using
25.
Catch
ex
As
Exception
26.
ts.Rollback()
27.
End
Try
28.
End
Using
29.
End
Using
30.
End
Sub
31.
End
Class