|
ちなみに1件づつInsertするだけならSqlDataSourceを使わなくても
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Using connection As New SqlConnection(WebConfigurationManager.ConnectionStrings("MyNorthWindConnectionString").ConnectionString)
connection.Open()
Dim command As New SqlCommand("INSERT INTO ユーザ(会社名, 氏名, タイプ) VALUES (@company, @name, @type)", connection)
command.Parameters.AddWithValue("@company", "xxx1")
command.Parameters.AddWithValue("@name", "yyy1")
command.Parameters.AddWithValue("@type", "zzz1")
Dim result As Integer = command.ExecuteNonQuery()
Label1.Text = result.ToString() + "件処理されました"
connection.Close()
End Using
End Sub
こんな感じで同様の結果は得られるかと思われます。
|