|
 |
ado_dotnet thread: ADO.NET update
Message #1 by jmpolain@t... on Sat, 8 Mar 2003 20:55:21
|
|
I have used the code of the VB.NET 2nd edition chapter 16: Data binding.
The process of showing records on a windows form with textbox binded to
one table works. I have also add a buttonwith one textbox to do a search
in the table proceeding character per character.
But my problem is when I want to update one record.
My code is :
Dim connection As New SqlConnection(ConnectionString)
connection.Open()
Dim adapter As New SqlDataAdapter(GetClientString, connection)
Dim builder As New SqlCommandBuilder(adapter)
adapter.Update(_Clients)
adapter.Dispose()
connection.Close()
When I audit the access on the SQL server with SQL profiler, I detect
that there is no access when I do a new connection and open it and the
for the update. It seems that the first connection stays open and that
the update don't works in this case.
Any idea ?
Jean-Marie Polain
Message #2 by jmpolain@t... on Fri, 14 Mar 2003 18:57:37
|
|
The answer was in the errata of the book :
In the onchange event of the dataset, the method EndEdit instead of
HasChanges must me used.
Jean-Marie Polain
> I have used the code of the VB.NET 2nd edition chapter 16: Data binding.
> The process of showing records on a windows form with textbox binded to
o> ne table works. I have also add a buttonwith one textbox to do a
search
i> n the table proceeding character per character.
> But my problem is when I want to update one record.
> My code is :
D> im connection As New SqlConnection(ConnectionString)
> connection.Open()
> Dim adapter As New SqlDataAdapter(GetClientString, connection)
> Dim builder As New SqlCommandBuilder(adapter)
> adapter.Update(_Clients)
> adapter.Dispose()
> connection.Close()
W> hen I audit the access on the SQL server with SQL profiler, I detect
t> hat there is no access when I do a new connection and open it and the
f> or the update. It seems that the first connection stays open and that
t> he update don't works in this case.
> Any idea ?
> Jean-Marie Polain
|
|
 |