1

ボタンを押すと、Sname と SNo がデータベースに書き込まれます。これが私のコードです:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim ConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\cerns1\Local Settings\Application Data\Temporary Projects\WindowsApplication1\testdb.accdb"
    Dim cnn As New OleDbConnection(ConnString)

    ' Create a new row. 
    Dim newStudentRow As testdbDataSet.StudentRow
    newStudentRow = Me.TestdbDataSet.Student.NewStudentRow()


    ' Save the new row to the database 
    Dim i As Integer = 2
    Dim SNo As Integer = 1
    Do While i > 1
        cnn.Open()
        'StudentTableAdapter.Insert("WOW", SNo)
        Me.TestdbDataSet.Student.Rows.Add(newStudentRow)
        Me.StudentTableAdapter.Update(Me.TestdbDataSet.Student)
        SNo = SNo + 1
        i = i + 1
        cnn.Close()
    Loop


End Sub

実行後、Access データベースに情報が追加または変更されることはありません。

4

1 に答える 1