如何将Datatable里的数据批量的插入表里
如题,以下是我单条的插入数据,如何批量的插入呢,请大家修改一下:
If MsgBox("是否要更新到数据库?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
If sqlconn.State <> ConnectionState.Open Then
sqlconn.Open()
End If
Dim MyAdapter As New SqlDataAdapter
Dim sql As String = "insert into attend(empid,in_date,in_time) values" _
& "( '" & Me.DataGrid1.Item(Me.DataGrid1.CurrentRowIndex, 0) & "'," _
& "'" & Me.DataGrid1.Item(Me.DataGrid1.CurrentRowIndex, 1) & "'," _
& "'" & Me.DataGrid1.Item(Me.DataGrid1.CurrentRowIndex, 2) & "')"
MyAdapter.InsertCommand = New SqlCommand(sql, sqlconn)
MyAdapter.InsertCommand.ExecuteNonQuery()
End If