473,387 Members | 1,431 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,387 software developers and data experts.

Overwriting Byte Arrays from DataGridView

This error occurs when chaning the "Badge Number" field of my database, the program is taking the photo of the record that is being changed and copies it to the NEXT record in the DataGridView overwriting the photo for that particular person.

If anyone has any kind of knowledge of working with DataGrids I would appreciate some help. Here are the pieces of code that are executed when I get the overwrite bug....

Expand|Select|Wrap|Line Numbers
  1.     Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
  2.         If (Badge_NumberTextBox.Text.Length <= 0) Then
  3.             Badge_NumberTextBox.ForeColor = Color.Red
  4.             MessageBox.Show("Badge Number cannot be blank!", "Enter a value for the badge number", MessageBoxButtons.OK)
  5.         Else
  6.             dgridBadges.CurrentRow.Cells.Item(5).Value = Issue_DateDateTimePicker.Value.ToShortDateString
  7.             dgridBadges.CurrentRow.Cells.Item(8).Value = Expiration_DateDateTimePicker.Value.ToShortDateString
  8.             Me.Validate()
  9.             Me.TableContractorBadgesBindingSource.EndEdit()  'this line causes execution to branch to the dgridBadges_RowLeave sub, followed by dgrid_Badges_SelectionChanged sub, then returns to here
  10.             Me.TableAdapterContractorBadges.Update(Me.DatasetContractorBadges.Table_Contractor_Badges)
  11.             dgridBadges.Sort(dgridBadges.Columns.Item(0), System.ComponentModel.ListSortDirection.Ascending)   'This causes the dgridBadges_RowLeave sub to execute one last time
  12.         End If
  13.     End Sub

Expand|Select|Wrap|Line Numbers
  1.     Private Sub dgridBadges_RowLeave(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgridBadges.RowLeave
  2.         If Me.IsEmpty = True Then
  3.             Me.IsEmpty = False
  4.             DeleteRecord()
  5.             DecrementBadgeNumber()
  6.         End If
  7.     End Sub

Expand|Select|Wrap|Line Numbers
  1.     Private Sub dgridBadges_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgridBadges.SelectionChanged
  2.         If Me.IsEmpty = False And Me.dgridBadges.Rows.Count > 0 Then
  3.             Dim Converter As New ImageConverter
  4.             Dim Cells As DataGridViewCellCollection
  5.             Cells = Me.dgridBadges.CurrentRow.Cells
  6.  
  7.             Badge_NumberTextBox.Text = Cells.Item(0).Value.ToString.Trim()
  8.             First_NameTextBox.Text = Cells.Item(1).Value.ToString.Trim()
  9.             Last_NameTextBox.Text = Cells.Item(2).Value.ToString.Trim()
  10.             CompanyTextBox.Text = Cells.Item(3).Value.ToString.Trim()
  11.             UNSMC_NumberTextBox.Text = Cells.Item(4).Value.ToString.Trim()
  12.             Sponsor_NameTextBox.Text = Cells.Item(6).Value.ToString.Trim()
  13.             Sponsor_DepartmentTextBox.Text = Cells.Item(7).Value.ToString.Trim()
  14.  
  15.             If Cells.Item(9).Value Is DBNull.Value Then
  16.                 Me.PhotoPictureBox.Image = Nothing
  17.             Else
  18.                 Me.PhotoPictureBox.Image = Converter.ConvertFrom(Cells.Item(9).Value)
  19.             End If
  20.  
  21.         End If
  22.     End Sub
Any help would be greatly appreciated! Thanks
Jun 3 '08 #1
1 1568
Dököll
2,364 Expert 2GB
Greetings, Beagley!

Just pasing through but wanted to let you know to stay tuned, you're bound to get an answer. This also means I could not help in this case:-)

Good luck... also have a great week-end Beagley, looks like a hot one here here in Upstate NY!

Dököll
Jun 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Peter | last post by:
Hi how can I compare two byte arrays in VB.NET Thank Peter
9
by: Robert | last post by:
Hi, Is it me or is the recv() function not erasing but only overwriting the last data it supplied? example: when i first send: "login robert test"
1
by: Eric Hendriks | last post by:
// In an unmanaged DLL the following function must be called: // int VFGeneralize(const BYTE * const * features); // "features" parameter is supposed to be an array of byte arrays. // function is...
7
by: War Eagle | last post by:
I have two byte arrays and a char (the letter S) I was to concatenate to one byte array. Here is what code I have. I basically want to send this in a one buffer (byte array?) through a socket. ...
8
by: Ben Terry | last post by:
What's the most efficient way to transfer data from a byte to a struct? The struct is rather complex--contains other structs as well as byte members. I've tried to use Marshal.Copy and an IntPtr...
7
by: Joseph Lee | last post by:
Hi All, I am having problem when i am using hashtable to keep an array of bytes value as keys. Take a look at the code snippet below --------------------------------------------------- ...
6
by: Dennis | last post by:
I was trying to determine the fastest way to build a byte array from components where the size of the individual components varied depending on the user's input. I tried three classes I built: (1)...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
27
by: Jason | last post by:
Hi, I need to open an existing file, seek to a position at X number of bytes, and write out Y number of bytes overwriting any existing bytes, but no erasing any other data. Is this possible? ...
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
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
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?
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
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...

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.