I have got a problem with establishing ID of a new dataset entry. The new entry is returning NullValue for ID but if i get item(1) or bigger then i get normal data.
Dim id as integer
dbProvider = "Provider=Microsoft.JET.OLEDB.4.0;"
TheDatabase = "\dbMag.mdb"
MyDocFolder = Directory.GetCurrentDirectory()
FullDatabasePath = MyDocFolder & TheDatabase
dbSource = "Data Source = " & FullDatabasePath
con.ConnectionString = dbProvider & dbSource
Try
con.Open()
sqlString = "SELECT * FROM mag"
da = New OleDb.OleDbDataAdapter(sqlString, con)
da.Fill(ds, "mag")
con.Close()
Catch ex As Exception
MsgBox("Błąd: ", Err.Description)
End Try
Dim cb As New OleDb.OleDbCommandBuilder(da)
dsNewRow = ds.Tables("mag").NewRow()
With dsNewRow
'do something
end with
ds.Tables("mag").Rows.Add(dsNewRow)
da.Update(ds, "mag")
lastrow = ds.Tables("mag").Rows.Count - 1
id = ds.Tables("mag").Rows(lastrow).Item(0)
id is returning NullValue
Found solution: