?
Solved

SQLEXPRESS database emptied every time i compile???

Posted on 2006-05-28
18
Medium Priority
?
242 Views
Last Modified: 2010-04-16
Hello I read somewhere that everytime i compile my vs2005 c# windows form application it overwrite the database, or empties it of the info u put in while ur app was running.  So if I added 10 records while it was running they will not be there when i run my app the next time.

How do i stop this and make the database changes persist from one compile to the next?
0
Comment
Question by:joshuadavidlee
  • 8
  • 7
  • 3
18 Comments
 
LVL 5

Expert Comment

by:aaronfeng
ID: 16779905
I don't know where you read that because that is not true.  If you app persist something to be database, it will stay there unless you explicitly delete everything when the app shuts down.  All the data will stay in the database no matter how many times you compile.

Cheers,

Aaron
http://aaronfeng.blogspot.com/
0
 

Author Comment

by:joshuadavidlee
ID: 16779910
i mean when i compile and run in the development environment each time, and yeah i did read that and yeah i see the behaviour myself
0
 
LVL 5

Expert Comment

by:aaronfeng
ID: 16779926
Maybe I'm missing something.  If you have a link to the page, I would be interested in reading it.  Is there code in the app that explicitly deletes all the records from db after the app terminates?  The app you are running, did you write it or is it a sample from some where?

Cheers,

Aaron
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:joshuadavidlee
ID: 16779929
its my own, and i think the data is persisting in some temp folder cause sometimes it remebers the data in my app when i rerun it but never in the databse in the server explorer bar, and i will try and find that page again
0
 
LVL 5

Expert Comment

by:aaronfeng
ID: 16779944
Do you have the source code that you can post?  Are you saving data into a database?  The reason I asked it's because you said "data is persisting in some temp folder..." What type of database are you using?

Cheers,

Aaron
0
 

Author Comment

by:joshuadavidlee
ID: 16779947
ooops sorry, should have said sqlexpress, and i am using the tableadapter.insert method, and the sql express database was created "within" my app, and is part of my app folder tree
0
 
LVL 5

Expert Comment

by:aaronfeng
ID: 16779978
Why are you creating the database every time you run the app?  That is probably your problem, if you don't create the database every time when you run the app the data will persist across multiple runs.

Cheers,

Aaron
0
 

Author Comment

by:joshuadavidlee
ID: 16780048
um i dont create the database eachtime i dont think? I just do as they say, right click on project folder and choose to add a new iten, and then i choose a database item
0
 
LVL 2

Expert Comment

by:HeidarV
ID: 16781940
hello

can i see the part of your code involving sql?

Heidar
0
 

Author Comment

by:joshuadavidlee
ID: 16781948
 this.tbn_ChannelTagsTableAdapter1.Insert(theChannel_ID, theTag);
0
 
LVL 5

Expert Comment

by:aaronfeng
ID: 16781974
Put a break point after you insert data into the database, not on the line of insert, after it.  When the break point stops, go to your database and check the table see if the value just got inserted appears in the table.  If it doesn't the data is never making into the database.

Cheers,

Aaron
0
 

Author Comment

by:joshuadavidlee
ID: 16781984
ok i know this all sounds weird, but yes it is and no its not making it into the table.
I have drawn a gridview on my form and yes the items show up in the gridview and i can edit them and everything however they r not making it into the "real" database and persiting from compile to compile
0
 
LVL 2

Expert Comment

by:HeidarV
ID: 16782000
hello

if this line runs without exception it seems good. is there any other code which refers to sql?
do you have sql management studio and if yes can you see your inserted row in management studio after insert?

Heidar
0
 
LVL 5

Expert Comment

by:aaronfeng
ID: 16782006
Yes, that would answer your question on why you thought you database was getting wiped out during each compile.  When you see data in the grid has nothing to do with data being persisted to the database or not, you can populate the data in the grid without saving it to database.  Once you persist the data to the database it will stay there regardless of if you are recompiling the code.  The first step for you to do is actually persist the data into the database then read it back from database then populate the grid with it.

Cheers,

Aaron
0
 

Author Comment

by:joshuadavidlee
ID: 16782007
i do not have the studio installed. and i click on show data in the server explorer and its empty.  Anyways i read about this somehwere and it has something to do with deploying the app with a clean copy of the sqlexpress database or something like that
0
 

Author Comment

by:joshuadavidlee
ID: 16782011
ok to arron ,  NO NO NO, sorry, what i mean is i used the insert command in a another area of code, and somewhere else i used a grid to grab the data, they r not related cause i did not insert the data using the gridview
0
 
LVL 2

Expert Comment

by:HeidarV
ID: 16782020
Hello

if you can attach your file to sqlexpress i think everything will be ok. i havn't worked with sql database file but i have worked with sqlexpress and didn't see this problem.

Heidar

0
 
LVL 5

Accepted Solution

by:
aaronfeng earned 1500 total points
ID: 16782028
Right when you deploy your app, generally whoever uses it will start out with a blank database because there is no data yet.  If you need default data to start out you need to create a script that populates the database.  This is true for any database app using any language, it has nothing to do with WinForms app.

Cheers,

Aaron
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Integration Management Part 2
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question