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

Text box Has Changes

I have a simple form where I am using a dataset called Client. On the data
entry screen, there are name, address, city state and zip.

I have the fields bound to the dataset field. (Properties screen: Data
bindings then Text )

When I run the program and make a change to an existing record in the City
text box, the Dataset value for this column is changed as expected. When I
check the HasChanges property it says false. I don't understand why!

Seems I am missing something here. Because when I try to update the
database, it isn't taking the changes. I think it must have something to do
with how I have the text box is binding to the dataset. Is the data binding
process correct using the Text property field? Should I be going to the
Data Binding Tag property? Do I set both the Data Binding Tag and Text?
Are there other properties I need to set?

Any suggestions?

Thanks in advance.
Lance


Nov 20 '05 #1
6 4179
Hi Lance,

A couple of questions:
1. do the other columns update correctly?
2. are you calling the dataadapter update method?

If you could zip me up some code, I probably could help you solve the
matter.

HTH,

Bernie Yaeger
be*****@cherwellinc.com
"Lance Geeck" <lg****@cox.net> wrote in message
news:aKK6b.29803$S_.26995@fed1read01...
I have a simple form where I am using a dataset called Client. On the data entry screen, there are name, address, city state and zip.

I have the fields bound to the dataset field. (Properties screen: Data
bindings then Text )

When I run the program and make a change to an existing record in the City
text box, the Dataset value for this column is changed as expected. When I check the HasChanges property it says false. I don't understand why!

Seems I am missing something here. Because when I try to update the
database, it isn't taking the changes. I think it must have something to do with how I have the text box is binding to the dataset. Is the data binding process correct using the Text property field? Should I be going to the
Data Binding Tag property? Do I set both the Data Binding Tag and Text?
Are there other properties I need to set?

Any suggestions?

Thanks in advance.
Lance

Nov 20 '05 #2
HI Bernie,

Thanks for responding.

1. None of the textbox fields update. The dbbank1.hasChanges comes up
False. This happens even if the values in the text box have changed and
the dataset shows the change in that column.
2. Here is the code:
************ Code **************************
Public Class frmBankMnt
Inherits System.Windows.Forms.Form
Dim ws As New BanksClient.localhost.BankService
Dim addmntflag As addmntflag 'holds passed values and enum on
adding\mnt

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents DsBank1 As BanksClient.localhost.dsBank
Friend WithEvents btnSave As System.Windows.Forms.Button
Friend WithEvents btnCancel As System.Windows.Forms.Button
Friend WithEvents txtBankName As System.Windows.Forms.TextBox
Friend WithEvents txtContactName As System.Windows.Forms.TextBox
Friend WithEvents txtEmailAddress As System.Windows.Forms.TextBox
Friend WithEvents txtPhoneNbr As System.Windows.Forms.TextBox
Friend WithEvents txtAddress As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents txtFax As System.Windows.Forms.TextBox
Friend WithEvents txtCity As System.Windows.Forms.TextBox
Friend WithEvents txtState As System.Windows.Forms.TextBox
Friend WithEvents txtZip As System.Windows.Forms.TextBox
Friend WithEvents txtLastUpdate As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.DsBank1 = New BanksClient.localhost.dsBank
Me.btnSave = New System.Windows.Forms.Button
Me.btnCancel = New System.Windows.Forms.Button
Me.txtBankName = New System.Windows.Forms.TextBox
Me.txtContactName = New System.Windows.Forms.TextBox
Me.txtEmailAddress = New System.Windows.Forms.TextBox
Me.txtPhoneNbr = New System.Windows.Forms.TextBox
Me.txtFax = New System.Windows.Forms.TextBox
Me.txtAddress = New System.Windows.Forms.TextBox
Me.txtCity = New System.Windows.Forms.TextBox
Me.txtState = New System.Windows.Forms.TextBox
Me.txtZip = New System.Windows.Forms.TextBox
Me.txtLastUpdate = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.Label7 = New System.Windows.Forms.Label
Me.Label8 = New System.Windows.Forms.Label
CType(Me.DsBank1,
System.ComponentModel.ISupportInitialize).BeginIni t()
Me.SuspendLayout()
'
'DsBank1
'
Me.DsBank1.DataSetName = "dsBank"
Me.DsBank1.Locale = New
System.Globalization.CultureInfo("en-US")
'
'btnSave
'
Me.btnSave.Location = New System.Drawing.Point(139, 224)
Me.btnSave.Name = "btnSave"
Me.btnSave.TabIndex = 1
Me.btnSave.Text = "Save"
'
'btnCancel
'
Me.btnCancel.Location = New System.Drawing.Point(275, 224)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.TabIndex = 2
Me.btnCancel.Text = "Cancel"
'
'txtBankName
'
Me.txtBankName.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.BankName"))
Me.txtBankName.Location = New System.Drawing.Point(112, 24)
Me.txtBankName.Name = "txtBankName"
Me.txtBankName.Size = New System.Drawing.Size(368, 20)
Me.txtBankName.TabIndex = 3
Me.txtBankName.Text = ""
'
'txtContactName
'
Me.txtContactName.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.ContactName"))
Me.txtContactName.Location = New System.Drawing.Point(112, 48)
Me.txtContactName.Name = "txtContactName"
Me.txtContactName.Size = New System.Drawing.Size(368, 20)
Me.txtContactName.TabIndex = 4
Me.txtContactName.Text = ""
'
'txtEmailAddress
'
Me.txtEmailAddress.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.EMailAddress"))
Me.txtEmailAddress.Location = New System.Drawing.Point(112, 72)
Me.txtEmailAddress.Name = "txtEmailAddress"
Me.txtEmailAddress.Size = New System.Drawing.Size(288, 20)
Me.txtEmailAddress.TabIndex = 5
Me.txtEmailAddress.Text = ""
'
'txtPhoneNbr
'
Me.txtPhoneNbr.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.PhoneNumber"))
Me.txtPhoneNbr.Location = New System.Drawing.Point(112, 96)
Me.txtPhoneNbr.Name = "txtPhoneNbr"
Me.txtPhoneNbr.Size = New System.Drawing.Size(144, 20)
Me.txtPhoneNbr.TabIndex = 6
Me.txtPhoneNbr.Text = ""
'
'txtFax
'
Me.txtFax.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.Fax"))
Me.txtFax.Location = New System.Drawing.Point(368, 96)
Me.txtFax.Name = "txtFax"
Me.txtFax.Size = New System.Drawing.Size(112, 20)
Me.txtFax.TabIndex = 7
Me.txtFax.Text = ""
'
'txtAddress
'
Me.txtAddress.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.Address"))
Me.txtAddress.Location = New System.Drawing.Point(112, 128)
Me.txtAddress.Name = "txtAddress"
Me.txtAddress.Size = New System.Drawing.Size(368, 20)
Me.txtAddress.TabIndex = 8
Me.txtAddress.Text = ""
'
'txtCity
'
Me.txtCity.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.City"))
Me.txtCity.Location = New System.Drawing.Point(112, 152)
Me.txtCity.Name = "txtCity"
Me.txtCity.Size = New System.Drawing.Size(224, 20)
Me.txtCity.TabIndex = 9
Me.txtCity.Text = ""
'
'txtState
'
Me.txtState.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.State"))
Me.txtState.Location = New System.Drawing.Point(344, 152)
Me.txtState.Name = "txtState"
Me.txtState.Size = New System.Drawing.Size(24, 20)
Me.txtState.TabIndex = 10
Me.txtState.Text = ""
'
'txtZip
'
Me.txtZip.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.Zip"))
Me.txtZip.Location = New System.Drawing.Point(376, 152)
Me.txtZip.Name = "txtZip"
Me.txtZip.TabIndex = 11
Me.txtZip.Text = ""
'
'txtLastUpdate
'
Me.txtLastUpdate.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsBank1, "Bank.LastUpdate"))
Me.txtLastUpdate.Location = New System.Drawing.Point(304, 184)
Me.txtLastUpdate.Name = "txtLastUpdate"
Me.txtLastUpdate.TabIndex = 12
Me.txtLastUpdate.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(176, 184)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 13
Me.Label1.Text = "Last Update"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 128)
Me.Label3.Name = "Label3"
Me.Label3.TabIndex = 15
Me.Label3.Text = "Address"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(328, 96)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(32, 23)
Me.Label4.TabIndex = 16
Me.Label4.Text = "Fax"
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(8, 96)
Me.Label5.Name = "Label5"
Me.Label5.TabIndex = 17
Me.Label5.Text = "Phone"
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(8, 72)
Me.Label6.Name = "Label6"
Me.Label6.TabIndex = 18
Me.Label6.Text = "E-Mail Address"
'
'Label7
'
Me.Label7.Location = New System.Drawing.Point(8, 48)
Me.Label7.Name = "Label7"
Me.Label7.TabIndex = 19
Me.Label7.Text = "Contact Name"
'
'Label8
'
Me.Label8.Location = New System.Drawing.Point(8, 24)
Me.Label8.Name = "Label8"
Me.Label8.TabIndex = 20
Me.Label8.Text = "Bank Name"
'
'frmBankMnt
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(488, 273)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.txtLastUpdate)
Me.Controls.Add(Me.txtZip)
Me.Controls.Add(Me.txtState)
Me.Controls.Add(Me.txtCity)
Me.Controls.Add(Me.txtAddress)
Me.Controls.Add(Me.txtFax)
Me.Controls.Add(Me.txtPhoneNbr)
Me.Controls.Add(Me.txtEmailAddress)
Me.Controls.Add(Me.txtContactName)
Me.Controls.Add(Me.txtBankName)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnSave)
Me.Name = "frmBankMnt"
Me.Text = "Bank Entry and Editing"
CType(Me.DsBank1,
System.ComponentModel.ISupportInitialize).EndInit( )
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub frmAddMnt_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ws.Credentials = System.Net.CredentialCache.DefaultCredentials
DsBank1.Merge(ws.GetAllBanks)
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
DsBank1.GetChanges()
If DsBank1.HasChanges() Then
ws.Credentials =
System.Net.CredentialCache.DefaultCredentials
Dim diffBank As New BanksClient.localhost.dsBank
'creates a dataset that holds the differences
'diffBank.Merge(DsBank1.GetChanges())
'puts the changes into this new dataset from dsbank1
diffBank = ws.UpdateBank(DsBank1) 'updates through the web
service
DsBank1.Merge(diffBank)
'changes are refreshed on dsbank1 it looks like.
End If

End Sub

Private Sub frmBankMnt_Disposed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Disposed, btnCancel.Click
Me.Dispose()
End Sub

Private Sub txtFax_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles txtFax.TextChanged
Debug.Write("Has changes? " & DsBank1.HasChanges.ToString)
'This always comes up false.
End Sub
End Class
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Add this line to your btn_SaveClick handler:

Me.BindingContext(Me.DsBank1, "Bank").EndCurrentEdit()

to make the method look like:

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

Me.BindingContext(Me.DsBank1, "Bank").EndCurrentEdit()

DsBank1.GetChanges()
If DsBank1.HasChanges() Then
ws.Credentials = System.Net.CredentialCache.DefaultCredentials()
Dim diffBank As New BanksClient.localhost.dsBank
'creates a dataset that holds the differences
'diffBank.Merge(DsBank1.GetChanges())
'puts the changes into this new dataset from dsbank1
diffBank = ws.UpdateBank(DsBank1) 'updates through the web service()
DsBank1.Merge(diffBank)
'changes are refreshed on dsbank1 it looks like.
End If

End Sub

When you make changes to the data in your TextBox controls, data-binding begins an edit that gets committed automatically when you scroll to a new record using something like this:

Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click
If (Me.BindingContext(Me.DsBank1, "Bank").Position > 0) Then
Me.BindingContext(Me.DsBank1, "Bank").Position = Me.BindingContext(Me.DsBank1, "Bank").Position - 1
End If
End Sub

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
If (Me.BindingContext(Me.DsBank1, "Bank").Position < Me.BindingContext(Me.DsBank1, "Bank").Count - 1) Then
Me.BindingContext(Me.DsBank1, "Bank").Position = Me.BindingContext(Me.DsBank1, "Bank").Position + 1
End If
End Sub

Without moving to a new record, it looks like the edit is never automatically committed for you, so you'll have to end the current edit manually (which commits your changes to the underlying DataSet) before you check to see if the DataSet has
been changed.

Let me know if that doesn't work for you, ok?

hth,
e-
--
eric knox, VB.Net Team
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4

Hi Eric,

That solved it. I couldn't figure out why the record wasn't being
commited.

Thanks for the help.

Lance
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5
One additional thing I thought of after I sent this was that you don't need to call DsBank1.GetChanges() stand-alone before calling DsBank1.HasChanges()

Calling GetChanges and passing that to the web-service to do the updating is a good thing to do, but calling it stand-alone and not doing anything with the returned DataSet is just wasted effort.

e-
--
eric knox, VB.Net Team
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: Lance Geeck <lg****@cox.net>
| References: <81*************@cpmsftngxa06.phx.gbl>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Re: Text box Has Changes
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <Oj**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| Date: Wed, 10 Sep 2003 15:49:03 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:136504
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
|
| Hi Eric,
|
| That solved it. I couldn't figure out why the record wasn't being
| commited.
|
| Thanks for the help.
|
| Lance
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|
Nov 20 '05 #6
That makes sense. I'll change it. It sure is a rough ride going from
VB 6 to .NET.

Thanks for the additional help.

Lance.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7

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

Similar topics

11
by: Ed Suominen | last post by:
I'm thinking of implementing a real-time collaborative text editor in Python using Twisted. An initial plan is to use a Twisted PB server daemon that accepts user:password:file connections from...
1
by: JLuppens | last post by:
Does anyone know if there is a way to track changes in a text field like word does? I am using a SQL2000 database and can use either VB.Net or Access. The field is either ntext or Varchar. I...
4
by: gj | last post by:
Hi, I'm trying to update a sql database from a web form using text boxes. I'm trying to learn C# on my own so I am at a complete loss. I created my sql connection, data adapter, dataset and data...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
2
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different...
5
by: Steve S | last post by:
Heres what I want to do...User types into a texbox, clicks a button, the button saves that text to a file. The problem is that when I click the submit button, any changes made to the textbox are...
8
by: addoty | last post by:
We have a web application that has a lot of large textareas for data collection. We need to track who makes changes, when and what changes were made. Right now I'm storing the entire text in a...
18
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the...
1
by: =?ISO-8859-1?Q?S=F8ren?= | last post by:
Hi guys I got the following code: ------------------------------------------------------- Dim Word As New Microsoft.Office.Interop.Word.Application Dim Document As...
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
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
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
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
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...

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.