Hi,
I have done this (it is using SQL because I have not Access database
anymore, but in fact it is the same as you read for Sql Oledb)
It did work perfectly
\\\
Imports System.Data.SqlClient
Public Class Form1
Private da As SqlDataAdapter
Private ds As New DataSet
Private Sub Form1_Load(ByVal sender As System.Object _
, ByVal e As System.EventArgs) Handles
MyBase.Load
da = New SqlDataAdapter("Select * from Employees where EmployeeID =
'1'" _
, "Data Source=MyServer;Initial
Catalog=Northwind;Integrated Security=True")
da.Fill(ds, "Employees")
TextBox1.DataBindings.Add("text", ds, "Employees.LastName")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.BindingContext(ds, "Employees").EndCurrentEdit()
Dim cb = New SqlCommandBuilder(da)
Me.da.Update(ds, "Employees")
End Sub
End Class
///
Cor
"tiki99 via DotNetMonster.com" <u42576@uwe> wrote in message
news:9224e8ad2aca7@uwe...
> Thanks Cor.
>
> I moved the code you supplied into the button_click event as follows:
>
> Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.
> EventArgs) Handles Button3.Click
>
> Me.BindingContext(Me.ds, "info").EndCurrentEdit()
>
> Dim cb As OleDbCommandBuilder
> cb = New OleDbCommandBuilder(da)
>
> MsgBox(ds.HasChanges())
> Me.da.Update(Me.ds, "info")
> Me.ds.AcceptChanges()
>
> End Sub
>
> It again showed that the dataset had changed, but again gave me the same
> error. Am I trying to do something that can't be done? In other words, I'm
> filling the textbox with data from the db. The user would then manually
> change the text in that texbox and click the update button. The new (text)
> information would then be saved(updated) to the database. I know how to
> manually insert or update an entire record into a database, I just thought
> this would be easier on a single field by field basis. I'm obviously
> missing
> some point here.
>
> If you have any other suggestions, I'd like to try them.
>
> thanks,
> Bob
>
> Cor Ligthert[MVP] wrote:
>>Tiki,
>>
>>What I mostly do as I use the commandbuilder is like this.
>>
>>> Imports System.Data.OleDb
>>> Public Class Form3
>>[quoted text clipped - 8 lines]
>>> System.EventArgs)
>>> Handles Me.Load
>>
>> Dim dbConn As New OleDbConnection(ConnectionString)
>> Dim queryString As String = "select * from Info where ClientNum =
>> '123'
>>"
>> da = New OleDbDataAdapter(queryString, dbConn)
>> dim cb As OleDbCommandBuilder(da)
>>
>> 'da.UpdateCommand = cb.GetUpdateCommand (You don't need these 3)
>> 'da.DeleteCommand = cb.GetDeleteCommand
>> 'da.InsertCommand = cb.GetInsertCommand
>>> da.Fill(ds, "info")
>> cb = new OleDBCommandBuilder(da)
>>> TextBox1.DataBindings.Clear()
>>> TextBox1.DataBindings.Add("text", ds, "info.address")
>>[quoted text clipped - 5 lines]
>>> Me.BindingContext(Me.ds, "info").EndCurrentEdit()
>>> MsgBox(ds.HasChanges())
>> Me.da.Update(ds, "info")
>> 'Me.ds.AcceptChanges() (only the changed rows are updated, and in
>>the update set as unchanged (status=new)
>>
>>> End Sub
>>
>>Cor
>
> --
> Message posted via DotNetMonster.com
> http://www.dotnetmonster.com/Uwe/For...b-net/200902/1
>