Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataBindings
Message
De
17/01/2004 18:09:42
 
 
À
17/01/2004 00:43:19
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00867747
Message ID:
00867854
Vues:
16
Why do you have two TextBoxes, but then try to fill the data by programmatically putting the data in the TextBoxes? I bet if you just fill out the data in the TextBoxes, as a user would, then you wouldn't have this problem. Because you're putting the data into the TextBoxes programmatically, I think it has to do with another .EndCurrentEdit() being needed, after you set the two .Text properties.

~~Bonnie


>Dear The Expert,
>
>Why NULL record added to the table .. I use below code..
>
>Dim X1, X2 as New TextBox
>
>in Form Load
>
>X1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.objmyds, "MyTable01.SalesCode"))
>X2.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.objmyds, "MyTable01.SalesName"))
>
>
>
>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
> Try
> 'Clear out the current edits
> Me.BindingContext(objmyds, "MyTable01").EndCurrentEdit()
> Me.BindingContext(objmyds, "MyTable01").AddNew()
>
> X1.Text = "88888"
> X2.Text = "WINANJAYA"
>
> Catch eEndEdit As System.Exception
> System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
> End Try
> Me.objmyds_PositionChanged()
> End Sub
>
> Public Sub UpdateDataSet()
> 'Create a new dataset to hold the changes that have been made to the main dataset.
> Dim objDataSetChanges As WindowsApplication1.DataSet1 = New WindowsApplication1.DataSet1()
> 'Stop any current edits.
> Me.BindingContext(objmyds, "MyTable01").EndCurrentEdit()
> 'Get the changes that have been made to the main dataset.
> objDataSetChanges = CType(objmyds.GetChanges, WindowsApplication1.DataSet1)
> 'Check to see if any changes have been made.
> If (Not (objDataSetChanges) Is Nothing) Then
> Try
> 'There are changes that need to be made, so attempt to update the datasource by
> 'calling the update method and passing the dataset and any parameters.
> Me.UpdateDataSource(objDataSetChanges)
> objmyds.Merge(objDataSetChanges)
> objmyds.AcceptChanges()
> Catch eUpdate As System.Exception
> 'Add your error handling code here.
> Throw eUpdate
> End Try
> 'Add your code to check the returned dataset for any errors that may have been
> 'pushed into the row object's error.
> End If
>
> End Sub
>
> Public Sub UpdateDataSource(ByVal ChangedRows As WindowsApplication1.DataSet1)
> Try
> 'The data source only needs to be updated if there are changes pending.
> If (Not (ChangedRows) Is Nothing) Then
> 'Open the connection.
> Me.SqlConnection1.Open()
> 'Attempt to update the data source.
> Me.SqlDataAdapter1.Update(ChangedRows)
> End If
> Catch updateException As System.Exception
> 'Add your error handling code here.
> Throw updateException
> Finally
> 'Close the connection whether or not the exception was thrown.
> Me.SqlConnection1.Close()
> End Try
>
> End Sub
>
>
>I need advice... thanks a lot in advance for any prompt reply ..
>
>Regards
>Winanjaya
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform