G
Gabriel Langen
Hi,
Here is a test code! Very simple and short!
The modify of row(0) doen't work but the add.row is OK!!!
I think, all the needed imports are OK!
Thanks
Imports System.Data
Imports System.Data.OleDb
Dim ds_Test As DataSet
Dim da_adapter As OleDbDataAdapter
Dim str_sql As String = "select * from liste_publications order by titre"
Dim str_conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\crisp.mdb"
Dim dr_test As DataRow
ds_Test = New DataSet("DS_Test")
da_adapter = New OleDbDataAdapter(str_sql, str_conn)
Dim SQLBuilder As OleDbCommandBuilder = New OleDbCommandBuilder(da_adapter)
Randomize()
da_adapter.Fill(ds_Test, "Table_1")
' Modify of row(0) : Not OK
ds_Test.Tables("Table_1").Rows(0)("Titre") = " Titre xxxx"
Dim x As String
If ds_Test.HasChanges Then
' Message is OK
msgbox("Changed")
ds_Test.Tables("Table_1").AcceptChanges()
da_adapter.Update(ds_Test, "Table_1")
End If
Dim ajout As Boolean
ajout = True
' add of two rows (OK)
If ajout Then
MsgBox(ds_Test.Tables("Table_1").TableName)
dr_test = ds_Test.Tables("Table_1").NewRow
dr_test("cle") = CStr(Int(Rnd() * 10000))
dr_test("auteur") = "Auteur"
dr_test("titre") = " Titres"
ds_Test.Tables("Table_1").Rows.Add(dr_test)
dr_test = ds_Test.Tables("Table_1").NewRow
dr_test("cle") = CStr(Int(Rnd() * 10000))
dr_test("auteur") = "Auteur"
dr_test("titre") = " Titres"
ds_Test.Tables("Table_1").Rows.Add(dr_test)
da_adapter.Update(ds_Test, "Table_1")
End If
da_adapter.Dispose()
ds_Test.Dispose()
End
Here is a test code! Very simple and short!
The modify of row(0) doen't work but the add.row is OK!!!
I think, all the needed imports are OK!
Thanks
Imports System.Data
Imports System.Data.OleDb
Dim ds_Test As DataSet
Dim da_adapter As OleDbDataAdapter
Dim str_sql As String = "select * from liste_publications order by titre"
Dim str_conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\crisp.mdb"
Dim dr_test As DataRow
ds_Test = New DataSet("DS_Test")
da_adapter = New OleDbDataAdapter(str_sql, str_conn)
Dim SQLBuilder As OleDbCommandBuilder = New OleDbCommandBuilder(da_adapter)
Randomize()
da_adapter.Fill(ds_Test, "Table_1")
' Modify of row(0) : Not OK
ds_Test.Tables("Table_1").Rows(0)("Titre") = " Titre xxxx"
Dim x As String
If ds_Test.HasChanges Then
' Message is OK
msgbox("Changed")
ds_Test.Tables("Table_1").AcceptChanges()
da_adapter.Update(ds_Test, "Table_1")
End If
Dim ajout As Boolean
ajout = True
' add of two rows (OK)
If ajout Then
MsgBox(ds_Test.Tables("Table_1").TableName)
dr_test = ds_Test.Tables("Table_1").NewRow
dr_test("cle") = CStr(Int(Rnd() * 10000))
dr_test("auteur") = "Auteur"
dr_test("titre") = " Titres"
ds_Test.Tables("Table_1").Rows.Add(dr_test)
dr_test = ds_Test.Tables("Table_1").NewRow
dr_test("cle") = CStr(Int(Rnd() * 10000))
dr_test("auteur") = "Auteur"
dr_test("titre") = " Titres"
ds_Test.Tables("Table_1").Rows.Add(dr_test)
da_adapter.Update(ds_Test, "Table_1")
End If
da_adapter.Dispose()
ds_Test.Dispose()
End