473,390 Members | 959 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,390 software developers and data experts.

Need some logic help

Hey guys I need some help with updateing an access database. I used OleDB
controls to set up my connection, adapter, and dataset.

The access table I am trying to update has these columns in this order:

CustomerID
Username
Password
Email
CustomerName
BillingAddress
ZipCode
PhoneNumber

I create my dataset and grab all the columns, but really all I am interested
in is being able to update CustomerName, BillingAddress, ZipCode, and
PhoneNumber.

The problem I am having is for example lets say I want to update the first
record's zip code. I enter in the new zipcode and click on my update record
button and it updates just the zip code for the first record, but then jumps
all the way down to the last record and copies the address in the last
record to the last records zip code, and phone number columns. Any ideas as
to why its doing this??

Thanks for any help!

Mike

Here is my code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
daCustomers.Fill(CustomersDS1)

End Sub

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click

Dim CommandBuilder As New OleDb.OleDbCommandBuilder(daCustomers)
Dim POS As Integer
With BindingContext(CustomersDS1, "Customers")
.Position = .Count - 1
POS = .Position
End With

CustomersDS1.Tables("Customers").Rows(POS).Item(4) = txtName.Text
CustomersDS1.Tables("Customers").Rows(POS).Item(5) = txtAddress.Text
CustomersDS1.Tables("Customers").Rows(POS).Item(6) = txtZip.Text
CustomersDS1.Tables("Customers").Rows(POS).Item(7) = txtPhone.Text

daCustomers.Update(CustomersDS1, "Customers")

End Sub

Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnFirst.Click

BindingContext(CustomersDS1, "Customers").Position = 0

End Sub

Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrev.Click

With BindingContext(CustomersDS1, "Customers")
If .Position > 0 Then .Position = .Position - 1
End With

End Sub

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNext.Click

With BindingContext(CustomersDS1, "Customers")
If .Position < .Count - 1 Then .Position = .Position + 1
End With

End Sub

Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
With BindingContext(CustomersDS1, "Customers")
.Position = .Count - 1
End With

End Sub
End Class
Jul 21 '05 #1
1 1315
Mike,

Well, I haven't used the database stuff much in .NET, but from what I can
glean, it is doing exactly what you are telling it to do.
If you look at the btnUpdate_Click method:
With BindingContext(CustomersDS1, "Customers") [GH] The following line sets the current position in your dataset to the
Last record .Position = .Count - 1
[GH] This line gets a copy of the current position, which is now the last
record. POS = .Position
End With
[GH] This line updates Row(POS), which is the last row, based on POS. CustomersDS1.Tables("Customers").Rows(POS).Item(4) = txtName.Text


I think the only reason your initial record is being updated "correctly" is
due to the fact that your dataset is bound.
Possibly you wanted those above lines swapped. Store the current position
first, then move to the end. But I still don't see where that would be
necessary or useful in this case.

Gerald
Jul 21 '05 #2

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

Similar topics

4
by: nc | last post by:
My iterator can find my collection when my Action class calls my jsp directly, however when my Action class calls an html file that is set up with IFrames (one of which is loading that same jsp), I...
3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
25
by: Bjørn T Johansen | last post by:
I need to write a SQL that calculates the interval between a start time and a stop time. This is the easy part. The problem is that I only have the time part, i.e. no date, so how can I be sure to...
7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
16
by: MS newsgroup | last post by:
I don't have clear reasons why we need business logic layer and data logic layer instead of having only data logic layer. Are there any good reasons for that?
10
by: David Thielen | last post by:
Hi; I have help html pages for each page of my ASP.NET webapp. So for the page datasource.aspx, I have help\datasource.htm. Bu what I want when the hyperlink is clicked, for it to look for the...
1
by: jonathan184 | last post by:
how to monitor and find out if files test1_* and test2_* files were sent in an hour and if not send an email This is on a unix system basically I got a cronjob that runs every sec polling a ftp dir...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
15
by: bruno.desthuilliers | last post by:
On 27 juin, 18:09, "John Salerno" <johnj...@NOSPAMgmail.comwrote: For which definitions of "content" and "logic" ??? The point of mvc is to keep domain logic separated from presentation logic,...
1
by: vijayarl | last post by:
Hi Everyone, i have the written this logic : basically a file operation open (CONFIGFILE, "$config_file") or die; while (<CONFIGFILE>) { chomp;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.