473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Any idea why my BindingSource won't update?

I have the following:

1 x .NET 2.0 .DLL

Containing one public DataSet (CustomerHandler) which contains one table and
a tableadapter to fill a datatable

1 x .NET 2.0 EXE

With a single form containing a DataSet (CustomerHandler1), a BindingSource
and a BindingNavigator. And also a whole load of textbox controls which are
databound to the BindingSource.

1 x SQL Server Express database

--

The problem is this:

When I enter the form, it reads the data perfectly and I can move from
record to record vis the BindingNavigator, and even add, delete and update
records. However, these changes are not being carried through to the
database - I ran SQL Server Profiler on the database and nothing was
happening at any stage, not even when the .EndEdit() method was called. I am
assuming that because I have a DataSet (CustomerHandler1) on my form, that
it is this that is being changed, and not the dataset in the satellite
assembly.

I want all my data in the satellite assembly as this is my data access layer
(DAL).

The code is as follows (CustomerHandler is the name of my dataset as defined
in the satellite assembly):

Dim CustomerHandlerTA As New
CustomerHandlerTableAdapters.II_CUSTOMERTableAdapt er

Try

CustomerHandlerTA = New CustomerHandlerTableAdapters.II_CUSTOMERTableAdapt er

CustomerHandlerTA.Fill(CustomerHandler1.II_CUSTOME R)

Catch ex As Exception

MsgBox(ex.Message)

Finally

CustomerHandlerTA = Nothing

End Try

Private Sub SaveChanges_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveChanges.Click

BindingSource.EndEdit()

End Sub

--

It all works perfectly in read-only mode and the dataset can be edited in
memory, but why aren't changes being propogated through to the database?

Any suggestions very warmly welcome!

Mike
Jan 7 '06 #1
1 8629
"Mike" <none> wrote in message news:eQ**************@TK2MSFTNGP11.phx.gbl...

Ok, I've fixed it - but my fix is just a hack. Basically, I can't call a
tableadapter update and pass in a dataset - I have to explicitally pass in a
datatable - this works. I can't access the TableAdapter that I create below
because it's out of scope in the SaveChanges_Click(..) function. So... I
moved the CustomerHandlerTA declaration and made it a friend variable at the
top of the module. Messy, is there a better way?

I also changed the SaveChanges_Click() such that I now call:

CustomerHandlerTA.Update(CustomerHandler1.II_CUSTO MER)
Again, messy. I'd rather call the BindingSource.EndEdit() method. Why
doesn't this method simply work on its own?

--

My next problem is I need to add more datatables to the dataset. How can I
go about updating an entire dataset in one go? One would have thought the
..EndEdit() method called on a BindingSource bound to a DataSet would work
fine.

If I create a DataTable which contained a SQL set of data from across
multiple tables, could I still insert new rows in this way? One would think
not, as the META-data describing the relationships between the various
original tables will have been lost in translation.

Thanks in advance for any advice!

Warm Regards,

Mike
Jan 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Geoff | last post by:
Hi folks Calling BindingSource.ResetCurrentItem() is changing the BindingSource.Position in a way I don't understand. If I'm understanding the docs correctly, ResetCurrentItem() should simply...
0
by: dev | last post by:
Hi Everyone, I'm a little confused with the .NET 2.0 BindingSource for WinForms. Is it possible to update, insert or delete database items through the BindingSource with a Typed data object as its...
4
by: Rob Dob | last post by:
Hi, I have both a Customer and a Orders Table, the key field is CustomerID. I also have a DataGrid that uses a BindingSource which uses a dataset which uses a join between the Customers table...
1
by: Rob Dob | last post by:
Hi, I have both a Customer and a Orders Table, the key field is CustomerID. I also have a DataGridView that uses a BindingSource created using a join between the Customers table and the Orders...
5
by: Randy | last post by:
Hi, I'm have a form with a listbox and a few textboxes on it. Based on the user's selection in the listbox, I want the bindingsource to update the textboxes with the corresponding values. I have...
7
by: Mike | last post by:
i have a small difficulties with BindingSource and dataGridView bind db has properly opened and bind doesn't works. Unfortunately I didn't find any good example how to connect MS Access with...
2
nev
by: nev | last post by:
I'm trying to learn how to save changes in my BindingSource. What is Me.Validate()? And do I need it everytime I do save the bindingsource? Is this correct? me.validate() '<-- What is this for?...
1
by: Daniel Jeffrey | last post by:
..Net 2.0 VStudio 2005 C# I know this is going to seem like a strange question, as even I am sure I have missed something - but I cant find it. I want a simple event on any of the objects...
0
Sepidar
by: Sepidar | last post by:
hi, I have a DataGridView on my winform linked to a BindingSource linked to a Linq to SQL class. My problem is when I update my underlying class, the BindingSource will not notified and my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.