Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,098 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,838 people online right now. Registration is fast and FREE... Join Now!




Database changes not saved

 
Reply to this topicStart new topic

Database changes not saved

TuxBrewer
23 Apr, 2008 - 01:15 PM
Post #1

New D.I.C Head
*

Joined: 6 Oct, 2007
Posts: 9


My Contributions
Ok I am writing my 1st VB program which makes use of a SQL database. I have no problem reading the data out of the database, and can insert data and change it, however after my program terminates all my additions and changes are gone. Not sure what I am missing.

TB
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Database Changes Not Saved
23 Apr, 2008 - 02:55 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Post your code and we will help you get to the root of the problem.
User is offlineProfile CardPM
+Quote Post

TuxBrewer
RE: Database Changes Not Saved
23 Apr, 2008 - 03:04 PM
Post #3

New D.I.C Head
*

Joined: 6 Oct, 2007
Posts: 9


My Contributions
Here is the code I a using

CODE

ReservationTableAdapter.InsertReservation(roomLabel.Text, startupForm.checkInDate.Value, startupForm.checkOutDate.Value, startupForm.ttlCost)
GuestTableAdapter.InsertGuest(userNameBox.Text, lastNameBox.Text, firstNameBox.Text, streetBox.Text, cityBox.Text, stateBox.Text, zipBox.Text, phoneBox.Text, cNbr, passwordBox.Text)


and here are the sql statements being used

CODE

INSERT INTO [dbo].[Reservation] ([Room Name], [Check-in Date], [Check-out Date], [Total Room Cost]) VALUES (@Room_Name, @p1, @p3, @Total_Room_Cost);
SELECT [Room Name], [Check-in Date], [Check-out Date], [Total Room Cost], [Confirmation Number] FROM Reservation WHERE ([Confirmation Number] = SCOPE_IDENTITY())

CODE

INSERT INTO [dbo].[Guest] ([User Name], [Last Name], [First Name], [Street], [City], [State], [Zip Code], [Phone Number], [Confirmation Number], [password]) VALUES (@User_Name, @Last_Name, @First_Name, @Street, @City, @State, @Zip_Code, @Phone_Number, @Confirmation_Number, @password);
SELECT [User Name], [Last Name], [First Name], Street, City, State, [Zip Code], [Phone Number], [Confirmation Number], password FROM Guest WHERE ([User Name] = @User_Name) AND (password = @password)


Everything works fine. While the program is running I can view the tables and all the data is there. End and restart the program and its gone.

TB

This post has been edited by TuxBrewer: 23 Apr, 2008 - 03:06 PM
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Database Changes Not Saved
23 Apr, 2008 - 04:18 PM
Post #4

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Where are you performing the update to the database with your TableAdapters?
User is offlineProfile CardPM
+Quote Post

TuxBrewer
RE: Database Changes Not Saved
23 Apr, 2008 - 04:35 PM
Post #5

New D.I.C Head
*

Joined: 6 Oct, 2007
Posts: 9


My Contributions
I gather all the data using a windows form.. the user hits submit and I execute my 2 SQL statements thru the tableadapters. I never use an UPDATE statement since I am only adding data not modifying existing data.

TB
User is offlineProfile CardPM
+Quote Post

TuxBrewer
RE: Database Changes Not Saved
23 Apr, 2008 - 05:09 PM
Post #6

New D.I.C Head
*

Joined: 6 Oct, 2007
Posts: 9


My Contributions
Thanks for the replies but I solved it. Was something trivial.

Finally tracked it down to the database being set to Copy Always at startup instead of just Copy if Newer.

Thanks again

TB
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:25AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month