473,471 Members | 4,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataBindings Help

Hey everyone...
I have what I hope is a simple question. I have a form with about a dozen
controls bound to a databinding source. That datasource is bound to a
dataset. Without using a binding navigator, how do I do anything with this
thing?? I can't for the life of me figure out how to add, update, etc... Is
this possible without the navigator?

Thanks!!
Feb 28 '06 #1
8 2216
Hello,

BindingSource component provide some method to add, update records, for
example, to add a record, call AddNew() method; to update, call EndEdit()
method; to remove a record, call remove() mthod. All these can be done
without a navigator.

Hope this help,

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 1 '06 #2
When I try to make this work I run into a problem. I call addnew and then
should be able to call endedit. However, when I do that I keep getting an
error kicked back about null values for columns. This happens with or
without data in my columns. Why is it its not recognizing the values I put
in my text boxes?? Does this make sense? As an example...

If I have a text box called Key and I put something in it I get a null
reference error. But, if after calling AddNew I set the value of my textbox
via code then it recognizes that value.

It seems like maybe I broke something with my databinding but it half way
works ...
"Luke Zhang [MSFT]" <lu******@online.microsoft.com> wrote in message
news:$4*************@TK2MSFTNGXA03.phx.gbl...
Hello,

BindingSource component provide some method to add, update records, for
example, to add a record, call AddNew() method; to update, call EndEdit()
method; to remove a record, call remove() mthod. All these can be done
without a navigator.

Hope this help,

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 1 '06 #3
Andrew,

Was it you that I showed yesterday this sample on our website?

http://www.vb-tips.com/default.aspx?...8-2e91e5295e7c

Otherwise I hope this helps,

Cor
"Andrew Bassett" <Fl******@community.nospam> schreef in bericht
news:O8**************@TK2MSFTNGP09.phx.gbl...
When I try to make this work I run into a problem. I call addnew and then
should be able to call endedit. However, when I do that I keep getting an
error kicked back about null values for columns. This happens with or
without data in my columns. Why is it its not recognizing the values I put
in my text boxes?? Does this make sense? As an example...

If I have a text box called Key and I put something in it I get a null
reference error. But, if after calling AddNew I set the value of my
textbox via code then it recognizes that value.

It seems like maybe I broke something with my databinding but it half way
works ...
"Luke Zhang [MSFT]" <lu******@online.microsoft.com> wrote in message
news:$4*************@TK2MSFTNGXA03.phx.gbl...
Hello,

BindingSource component provide some method to add, update records, for
example, to add a record, call AddNew() method; to update, call EndEdit()
method; to remove a record, call remove() mthod. All these can be done
without a navigator.

Hope this help,

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Mar 1 '06 #4
I think my problem was the lack of the CurrencyManager. I don't have one of
those anywhere ... Thanks for the quick reply, I'm off to explore.
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:eI**************@tk2msftngp13.phx.gbl...
Andrew,

Was it you that I showed yesterday this sample on our website?

http://www.vb-tips.com/default.aspx?...8-2e91e5295e7c

Otherwise I hope this helps,

Cor
"Andrew Bassett" <Fl******@community.nospam> schreef in bericht
news:O8**************@TK2MSFTNGP09.phx.gbl...
When I try to make this work I run into a problem. I call addnew and then
should be able to call endedit. However, when I do that I keep getting an
error kicked back about null values for columns. This happens with or
without data in my columns. Why is it its not recognizing the values I
put in my text boxes?? Does this make sense? As an example...

If I have a text box called Key and I put something in it I get a null
reference error. But, if after calling AddNew I set the value of my
textbox via code then it recognizes that value.

It seems like maybe I broke something with my databinding but it half way
works ...
"Luke Zhang [MSFT]" <lu******@online.microsoft.com> wrote in message
news:$4*************@TK2MSFTNGXA03.phx.gbl...
Hello,

BindingSource component provide some method to add, update records, for
example, to add a record, call AddNew() method; to update, call
EndEdit()
method; to remove a record, call remove() mthod. All these can be done
without a navigator.

Hope this help,

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Mar 1 '06 #5
On your example you have the following line....

cma = DirectCast(BindingContext(dt), CurrencyManager)

I'm having trouble making that work. If I try this...

cma = DirectCast(Me.Sites_MBindingSource, CurrencyManager)

I get an error stating I cannot convert a binding source to a Currency Manager. How can I make that work?

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message news:eI**************@tk2msftngp13.phx.gbl...
Andrew,

Was it you that I showed yesterday this sample on our website?

http://www.vb-tips.com/default.aspx?...8-2e91e5295e7c

Otherwise I hope this helps,

Cor


"Andrew Bassett" <Fl******@community.nospam> schreef in bericht
news:O8**************@TK2MSFTNGP09.phx.gbl...
When I try to make this work I run into a problem. I call addnew and then
should be able to call endedit. However, when I do that I keep getting an
error kicked back about null values for columns. This happens with or
without data in my columns. Why is it its not recognizing the values I put
in my text boxes?? Does this make sense? As an example...

If I have a text box called Key and I put something in it I get a null
reference error. But, if after calling AddNew I set the value of my
textbox via code then it recognizes that value.

It seems like maybe I broke something with my databinding but it half way
works ...
"Luke Zhang [MSFT]" <lu******@online.microsoft.com> wrote in message
news:$4*************@TK2MSFTNGXA03.phx.gbl...
Hello,

BindingSource component provide some method to add, update records, for
example, to add a record, call AddNew() method; to update, call EndEdit()
method; to remove a record, call remove() mthod. All these can be done
without a navigator.

Hope this help,

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




Mar 1 '06 #6
In my test, after call Addnew, the TextBox is changed to blank and I can
type some string in it. Then I click a button to call
bindingSource1.EndEdit() and this work.

Are all of the fileds in bindingSource bound to a control on the form?
Before EndEdit(), is each of these controls has a actual value? When you
get the exception like

Column 'abc' does not allow nulls.

You may check if the field 'abc' is bound to a control (for example, a
TextBox) and if it has a actual value
Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 2 '06 #7
You can do same thing without Navigator by using –
'Moves data item First
Private Sub btnMoveFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnMoveFirst.Click
Me.BindingContext(DA, "Employee").Position = 0
End Sub
'Moves data item Last
Private Sub btnMoveLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnMoveLast.Click
Me.BindingContext(DA, "Employee").Position = Me.BindingContext(DA,
"Employee").Count - 1
End Sub
'Moves data item Next
Private Sub btnMoveNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnMoveNext.Click
Me.BindingContext(DA, "Employee").Position -= 1
End Sub
'Moves data item Prev
Private Sub btnMovePrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnMovePrev.Click
Me.BindingContext(DA, "Employee").Position += 1
End Sub
'Add New item
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAddNew.Click
Dim instance As BindingNavigator
Dim value As ToolStripItem
value = instance.AddNewItem
instance.AddNewItem = value
End Sub
'Delete item
Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDel.Click
Dim instance As BindingNavigator
Dim value As ToolStripItem
value = instance.DeleteItem
instance.DeleteItem = value
End Sub

Mar 18 '06 #8
You can do the same without Navigator by using –
'Moves data item First
Private Sub btnMoveFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnMoveFirst.Click
Me.BindingContext(DA, "TBL").Position = 0
End Sub
'Moves data item Last
Private Sub btnMoveLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnMoveLast.Click
Me.BindingContext(DA, "TBL").Position = _
Me.BindingContext(DA,"TBL").Count - 1
End Sub
'Moves data item Next
Private Sub btnMoveNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnMoveNext.Click
Me.BindingContext(DA, "TBL").Position -= 1
End Sub
'Moves data item Prev
Private Sub btnMovePrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnMovePrev.Click
Me.BindingContext(DA, "Employee").Position += 1
End Sub
'Add New item
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAddNew.Click
Dim instance As BindingNavigator
Dim value As ToolStripItem
value = instance.AddNewItem
instance.AddNewItem = value
End Sub
'Delete item
Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDel.Click
Dim instance As BindingNavigator
Dim value As ToolStripItem
value = instance.DeleteItem
instance.DeleteItem = value
End Sub

As an alternative download IdeaBlade’s DevForce Express and use that for ORM (I don’t work for them – but use it extensively)

Apr 1 '06 #9

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

Similar topics

0
by: akadiri4 | last post by:
I am trying to bind a textbox to a dataset using VB.Net but it doesn't seem to work Here is the code: DS = New DataSet DA = New SqlDataAdapter(StrSQL, StrConn) DA.Fill(DS, "StrSQL")...
0
by: Richard | last post by:
Hi, I am trying to bind a datetime picker control to a column in a DataView and I get this exception: "Object reference not set to an instance of an object." Pseudo code looks like this: ...
0
by: Alpha | last post by:
Hi, I want to display the content of the textbox.text according to the item selected in the listbox. Below is my code that in run time I would get error saying can't not bind to the "ServiceName"...
9
by: HAN(removethis)twister | last post by:
I've tried to create 11 textboxes as variables (not actually visible in the program, not in Windows Form Designer) and have set DataBindings to the text properties of the TextBoxes BUT according to...
6
by: Graham Blandford | last post by:
Hi all, I haven't received any replies to a previous question I posted regarding problems I was having with databound textboxes.. so I'll try a different angle... Can anyone point me in the...
2
by: C Glenn | last post by:
This is admitedly vague. But so is my understanding of the problem. I'm using this chunk of code: retControl.DataBindings.Add(ctrlBinding.PropertyName,DataSource,BindingField); This resolves...
0
by: XenReborn | last post by:
Ok this should be simple. I made a form, added a combobox (for selecting items to edit, not for updating fields), several textboxes, a few checkboxes etc. On formshow it connects to my database,...
2
by: marcf | last post by:
Hi everyone, I've just studio using VS2008 and have a quick question regarding databindings, i'm fairly handy with vb6 so this question really relates to good practice rather than actual coding. ...
7
by: =?Utf-8?B?Tmljb2xhcw==?= | last post by:
Yes another question about databindings. All my controls are have databindings and works fine for navigating, adding, deleting etc. What I want is when I create a New record have those fields...
1
by: janj | last post by:
Hi all, I'm having a problem binding two object properties to properties of another object. The code below works as expected when only one binding is added but doesn't work at all (still compiles)...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.