Link to home
Start Free TrialLog in
Avatar of joshuadavidlee
joshuadavidlee

asked on

SQLEXPRESS database emptied every time i compile???

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?
Avatar of aaronfeng
aaronfeng

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/
Avatar of joshuadavidlee

ASKER

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
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
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
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
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
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
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
hello

can i see the part of your code involving sql?

Heidar
 this.tbn_ChannelTagsTableAdapter1.Insert(theChannel_ID, theTag);
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
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
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
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
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
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
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

ASKER CERTIFIED SOLUTION
Avatar of aaronfeng
aaronfeng

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial