I am at my wits end. I am trying to create a program that will add users to a database. I have read the various posts regarding the output file and have changed the Copy To Output File to Copy Never. I have also tried Copy If Newer. The database still does not retain my changes/additions. The code I have used is shown below.
Code Here...
Private Sub AddUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddUser.Click
Dim newUserRow As Database1DataSet.Table1Row
newUserRow = Me.Database1DataSet.Table1.NewTable1Row
newUserRow.Name = nameBox.Text
newUserRow.Password = Password.Text
Database1DataSet.Table1.Rows.Add(newUserRow)
Me.Table1TableAdapter.Update(Me.Database1DataSet.Table1)
Database1DataSet.AcceptChanges()
End Sub
Please help!

database saga
fpalang
Jeff,
Please consider the post called How to receive the Optimal Answer to your Answer at the top of the forum.
Thanks!!!
pcaddict
Thanks for the clarification. I had no idea what you were referring to. I'll try to be more specific with titles in the future.
Jeff
bikeman123
hi,
wrap your code in try and catch , second tableAdapter.update returns integer value telling how many rows affected capture this value and show it in a message box to see if your database was updated or not and post the result that you got plz
best regards
Solitaire
Thank you Jeff.
It is our hope that the entire community will profit from these practices.
Also does your account refer to Access or SQL
lalle
Thank you ever so much. Your information is helpful. Unfortunately my forte is Access. I really wish I could help. I can assure that you are in great hands.
Enjoy!
goke
mrtn
Chris Sells
OK, I can see nothing wrong with your code except that the AcceptChanges() statement is unnecessary (Update calls it anyway).
Of course, code is only about 1/4 the battle when dealing with database operations. I can only tell you it isn't the code.
Try copying the database to some location where you know you have permission, then change the connection string to point to that constant location. You wouldn't believe all the behind-the-scenes directory shifting that goes on when compiling and running code, and perhaps it is best if that darn database sits somewhere Visual Studio will not mess with it!
ripern
Hermes 68
AvalonCoder
AMD
I've sometimes noted differences between the .xsd file properties of certain fields and the actual database fields. Generally, this is caused by altering the properties in the .xsd file without making similar changes in the underlying database. To get around this, I make all my property settings on the underlying database, and re-issue the Configure command for the TableAdapter for each table that was changed.
I'm actually somewhat of a beginner when dealing with typed datasets (support for them was officially released, what, 6 months ago ). Maybe it's because I'm old-fashioned, but if there's no compelling need for data binding or typed datasets, I normally fall back to untyped datasets and plain old connections and adapters. I've kinda gotten used to filling in my own darn textboxes!
Shuang Ma - ?爽
ReneeC,
Funny you mentioned Access as I am trying to use Access in an atempt to solve my problems. This is to no avail, however. I created an Access database called CKAppUsers with a table called Users. The code I am using is shown below. I published the project as a trial and I still cannot get the database to update with new data.
Private Sub AddUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddUser.Click
Dim userDV As DataView = Me.CkAppUsersDataSet1.Users.DefaultView
Dim userRV As DataRowView = userDV.AddNew
Dim numrows As Integer
userRV("FirstName") = firstNameBox.Text
userRV("LastName") = lastNameBox.Text
userRV("Initials") = initialsBox.Text
userRV("Position") = positionCBox.SelectedItem
userRV("Password") = passwordBox.Text
userRV.EndEdit()
Me.CkAppUsersDataSet1.AcceptChanges()
Me.UsersTableAdapter1.Update(Me.CkAppUsersDataSet1.Users)
numrows = Me.CkAppUsersDataSet1.Users.Rows.Count
MsgBox(numrows)
End Sub
The messagebox displays the new number of rows. However, when I reopen the app the data is no longer there.
J. Washburn
I'd be happy to.
All titles go into a data for the benefit of the community search engine. Differentitated titles are most helpful to users of the community who are looking to solve their problems.
A title like "Database Saga" is highly undifferentitated" and a more descriptive title would be helpful to the community, now and in the future.