На всякий привожу код:
- Код: Выделить всё
Private sqlDa As OleDb.OleDbDataAdapter
Private sqlDT As DataTable = New DataTable
Private sqlDV As DataView = New DataView
Private sqlDS As New DataSet
Private sqlDR As DataRow
Private Sub GetData()
' Получение данных для грида
On Error GoTo ErrL
SQLstr = "exec Users_Select"
SQLstr = "SELECT IdUser, NameUser, DomenNameUser, FIOUser, IsAdmin, IsSpecial FROM T_Users"
sqlDa = New OleDb.OleDbDataAdapter(SQLstr, BuildConnectionString)
sqlDa.Fill(sqlDS)
Grid.DataSource = sqlDS.Tables(0).DefaultView
End Sub
Private Sub sAddRecord()
'Добавление новой записи
sqlDR = sqlDS.Tables(0).NewRow
sqlDR.BeginEdit()
sqlDR("NameUser") = ""
sqlDR("DomenNameUser") = ""
sqlDR("FIOUser") = "Новый пользователь"
sqlDR("IsAdmin") = 0
sqlDR("IsSpecial") = 0
sqlDR.EndEdit()
sqlDS.Tables(0).Rows.Add(sqlDR)
Dim sqlSB As OleDb.OleDbCommandBuilder
sqlSB = New OleDb.OleDbCommandBuilder(sqlDa)
sqlDa.InsertCommand = sqlSB.GetInsertCommand
sqlDa.Update(sqlDS, sqlDS.Tables(0).TableName)
sqlDS.AcceptChanges()
End Sub
За ранее спсибо всем ответившим.