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

Working with BindingSource & AddNew

I'm trying to add a new row to my database using the BindingSource. I
assume it is possible...

Below is my code snippet:
Dim drvZone As DataRowView
Try
drvZone = Me.ZonesBindingSource.AddNew()
drvZone.Row.Item(1) = ProcessID
drvZone.Row.Item(2) = Me.txtTop.Text
drvZone.Row.Item(3) = Me.txtLeft.Text
drvZone.Row.Item(4) = Me.txtBottom.Text
drvZone.Row.Item(5) = Me.txtRight.Text
drvZone.Row.Item(6) = Me.txtZoneName.Text
Me.ZonesTableAdapter.Update(Me.DsZones)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

I don't get any errors, but it also doesn't add a record to the
database. Can anyone tell me what I'm doing wrong, or how to go about
adding a record to the database using the BindingSource, or should I go
about it another way?

Thanks,
Dustin
Jul 7 '06 #1
2 10416
Nevermind. I figured it out.

Dustin Davis wrote:
I'm trying to add a new row to my database using the BindingSource. I
assume it is possible...

Below is my code snippet:
Dim drvZone As DataRowView
Try
drvZone = Me.ZonesBindingSource.AddNew()
drvZone.Row.Item(1) = ProcessID
drvZone.Row.Item(2) = Me.txtTop.Text
drvZone.Row.Item(3) = Me.txtLeft.Text
drvZone.Row.Item(4) = Me.txtBottom.Text
drvZone.Row.Item(5) = Me.txtRight.Text
drvZone.Row.Item(6) = Me.txtZoneName.Text
Me.ZonesTableAdapter.Update(Me.DsZones)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

I don't get any errors, but it also doesn't add a record to the
database. Can anyone tell me what I'm doing wrong, or how to go about
adding a record to the database using the BindingSource, or should I go
about it another way?

Thanks,
Dustin
Jul 7 '06 #2
How did you solve the problem? I think that I'm running into the same thing.
Thanks,

Matt

"Dustin Davis" wrote:
Nevermind. I figured it out.

Dustin Davis wrote:
I'm trying to add a new row to my database using the BindingSource. I
assume it is possible...

Below is my code snippet:
Dim drvZone As DataRowView
Try
drvZone = Me.ZonesBindingSource.AddNew()
drvZone.Row.Item(1) = ProcessID
drvZone.Row.Item(2) = Me.txtTop.Text
drvZone.Row.Item(3) = Me.txtLeft.Text
drvZone.Row.Item(4) = Me.txtBottom.Text
drvZone.Row.Item(5) = Me.txtRight.Text
drvZone.Row.Item(6) = Me.txtZoneName.Text
Me.ZonesTableAdapter.Update(Me.DsZones)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

I don't get any errors, but it also doesn't add a record to the
database. Can anyone tell me what I'm doing wrong, or how to go about
adding a record to the database using the BindingSource, or should I go
about it another way?

Thanks,
Dustin
Sep 1 '06 #3

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

Similar topics

0
by: Michael Rodriguez | last post by:
I have a custom business object collection based on the CSLA.NET framework from Rockfor Lhotka's "Expert C# Business Objects" book. I bound my winform to the object and when I open the screen the...
14
by: Mark B | last post by:
Our webhost (www.usbusinessweb.net) had a W2K IIS5 server crash after a scheduled hard-boot occurred during a ms-security patch install overnight. They couldn't get the server working again so they...
1
by: Leonardo | last post by:
Hi. I'm trying to build my first application with database access using VB 2005. I'm a VB 6 programmer and learning everything again has been challenging. I managed to write a code using some tips...
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...
8
by: MLH | last post by:
Here's a snippet from A97 HELP on AddNew... The record that was current before you used AddNew remains current. If you want to make the new record current, you can set the Bookmark property to...
1
by: Pieter | last post by:
Hi, I have a custom List that inherits from BindingList. It has some methods overloaded, like the Add/Insert/etc to add and remove some eventhandlers when adding or removing an item T of the...
2
by: Thammarat charoenchai. | last post by:
After I use BindingSource.AddNew Method. (in my code is OrderBindingSource.AddNew). How can I set field value. like Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As...
0
nev
by: nev | last post by:
When bindingsource.addnew, it fires positionchanged event. When movenext, moveprevious, etc, it also fires positionchanged event. If I am to place code in positionchanged event, how will I...
0
nev
by: nev | last post by:
Have any of you encountered this? And how did you correct it? bs.addnew() automatically moves the position to the new record. But mine doesn't. I have 3 bindingsources in my program, all...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.