|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Why won't my DataTable.Update?I have a .NET 2.0 .DLL assembly containing a dataset with three tables. I reference this from a standalone .NET 2.0 EXE. I am writing a login form which uses the single Dataset from the .NET 2.0 .DLL. One of the tables (staff) contains a TableAdapter that fills using a single parameter (@UserName). I am trying to code a simple login form for which I pass a username and read the password. All is well and fine with this, however I want to write back to the "lastlogon" column and update it with a timestamp. I'm only using one table, so this shouldn't be too difficult? The following code doesn't break at all, but the table never updates. What am I doing wrong? I'm worried that I might be updating my own TableAdapter in memory which is disconnected from the database, or my instance of my TableAdapter isn't connected to the satellite .DLL assembly. The satellite ..DLL assembly is strongly named and the Dataset Strongly Typed. Any ideas? Thanks in advance for any help! Dim StaffDT As Staff.STAFFDataTable Dim StaffTA As StaffTableAdapters.STAFFTableAdapter StaffDT = New Staff.STAFFDataTable StaffTA = New StaffTableAdapters.STAFFTableAdapter StaffTA.FillByUserName(StaffDT, UsernameTextBox.Text) ' Found this username If StaffDT.Rows.Count = 1 Then ' Check password If StaffDT.Rows(0).Item("password") = Trim(PasswordTextBox.Text) Then ' Mark this login attempt StaffDT.Rows(0).Item("lastlogon") = Now() ' Accept Changes StaffDT.AcceptChanges() ' Commit Changes StaffTA.Update(StaffDT) ' Show Switchboard (successful login) ShowSwitchboard() Else MsgBox("Incorrect Password", MsgBoxStyle.Exclamation, My.Application.Info.AssemblyName) End If Else MsgBox("This username cannot be found in the database. Please ask your system administrator to create a username for you", _ MsgBoxStyle.Exclamation, My.Application.Info.AssemblyName) End If "Mike" <none> wrote in message If I remove this line, everything works. Any idea why?news:%2331AczlEGHA.2712@TK2MSFTNGP10.phx.gbl... > ' Accept Changes > StaffDT.AcceptChanges() Also if anyone's reading this and knows how - where can I find the Data Form Wizard? It's not available on my development environment. Warm Regards, Mike Mike,
>> ' Accept Changes AcceptChanges is an abbreviation for>> StaffDT.AcceptChanges() > > If I remove this line, everything works. Any idea why? Accept changes in the dataset/datatable as if all updates are done. (One of the most misleading methods names for newbies and than they forget in never more). To push the changes from a control to a datasource you have to use the EndCurrentEdit http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsbindingmanagerbaseclassendcurrentedittopic.asp I hope this helps, Cor
Show quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message Oh yes, that was confusing! Thanks for the explanation.news:uYtAEEqEGHA.1816@TK2MSFTNGP11.phx.gbl... > Mike, > >>> ' Accept Changes >>> StaffDT.AcceptChanges() >> >> If I remove this line, everything works. Any idea why? > > AcceptChanges is an abbreviation for > > Accept changes in the dataset/datatable as if all updates are done. > (One of the most misleading methods names for newbies and than they forget > in never more). > To push the changes from a control to a datasource you have to use the I have a BindingNavigator rather than a BindingManager, yet when I call the > EndCurrentEdit > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsbindingmanagerbaseclassendcurrentedittopic.asp ..EndEdit() method on another form, nothing happens - I've tried checking SQL Profiler and no SQL statements go through to the database. Any ideas? Warm Regards, Mike Mike
The endedit does as far as I have seen nothing, If this is a problem try than that endcurrenedit In this sample you can see it used at the end http://www.vb-tips.com/default.aspx?ID=0bcf3aa6-0da7-4a6e-9061-ac8b53818af6 I hope this helps, Cor "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message I can't use EndCurrentEdit as it is not a method available in either the news:Olc4tx2EGHA.1424@TK2MSFTNGP12.phx.gbl... > Mike > > The endedit does as far as I have seen nothing, > > If this is a problem try than that endcurrenedit > > In this sample you can see it used at the end > > http://www.vb-tips.com/default.aspx?ID=0bcf3aa6-0da7-4a6e-9061-ac8b53818af6 > > I hope this helps, DataSet, BindingSource or BindingNavigator objects. > BindingContext(DirectCast(DataGridView1.DataSource, Mike> DataView)).EndCurrentEdit() <
Show quote
"Mike" <none> schreef in bericht BindingContext(StaffDT).EndCurrentEdit()news:%23E43Ss4EGHA.3000@TK2MSFTNGP14.phx.gbl... > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:Olc4tx2EGHA.1424@TK2MSFTNGP12.phx.gbl... >> Mike >> >> The endedit does as far as I have seen nothing, >> >> If this is a problem try than that endcurrenedit >> >> In this sample you can see it used at the end >> >> http://www.vb-tips.com/default.aspx?ID=0bcf3aa6-0da7-4a6e-9061-ac8b53818af6 >> >> I hope this helps, > > I can't use EndCurrentEdit as it is not a method available in either the > DataSet, BindingSource or BindingNavigator objects. > Probably, Or show otherwise the code where you bind your data to the controls. Cor "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message Does nothing.news:uOaTOB5EGHA.1816@TK2MSFTNGP11.phx.gbl... > BindingContext(StaffDT).EndCurrentEdit() > Or show otherwise the code where you bind your data to the controls. There is no code. This form was created completely in the Windows Form Designer. Mike |
|||||||||||||||||||||||