-
January 6th, 2008, 01:13 PM
#1
Added a new record in my database, but after rebuild, the record is gone
I once had this problem but I can't seem to fix it again :
When I run my database-application and in a certain table I add a new record.
The record stays in the table, even when I exit the application and rerun it.
But when I look at the table data in the database explorer the record doesn't show up.
When I do a rebuild solution, the record doesn't show up again in the application.
I have set the property "copy to output directory" to "Copy if newer" for both the database and the dataset (.mdf and .xsd)
Am I still doing something else wrong?
edit : I looked at my connection string and the .mdf file is in my main project directory and not in any bin or debug directory. I think I have to change the connection string, but I can't chnage it through the property window. (Its' greyed out)
Last edited by da_cobra; January 6th, 2008 at 01:30 PM.
-
January 6th, 2008, 04:27 PM
#2
Re: Added a new record in my database, but after rebuild, the record is gone
I'm not sure if you want the record to be persistent or not.
If you do, then set the copy options to 'never copy' and change the connection string to point to the full path of the .mdb file in the project. Also make sure you delete any old .mdb files in the debug or release folders.
If you don't want the data persistent, then change the copy options to 'always copy' and make sure the connection string points to the .mdb file located in the debug or release folder. You can make sure the program is not using the .mdb in the project folder by starting the program and then temporarily move the .mdb file from the project. If you can move the file, it means the program is still using the file from the project.
-
January 7th, 2008, 11:17 AM
#3
Re: Added a new record in my database, but after rebuild, the record is gone
thx for the reply, but I have 2 comments :
1) since english isn't my mother language : persistent = ???
2) Like I said in my first post : I can't change the connection string through the properties of the .mdf file, because the string is greyed out.
-
January 8th, 2008, 11:12 AM
#4
Re: Added a new record in my database, but after rebuild, the record is gone
Persistent justs means 'saved'.
Can you change the connection string in the dataset by setting a property at runtime?
-
January 9th, 2008, 12:02 PM
#5
Re: Added a new record in my database, but after rebuild, the record is gone
How do I change the connection string by setting the property @ runtime?
-
January 9th, 2008, 12:23 PM
#6
Re: Added a new record in my database, but after rebuild, the record is gone
Originally Posted by da_cobra
How do I change the connection string by setting the property @ runtime?
Post your code that opens and uses the dataset.
-
January 10th, 2008, 11:59 AM
#7
Re: Added a new record in my database, but after rebuild, the record is gone
ok, maybe I'm stupid but where can I find that code?
I added my dataset through the "add new item" => "sql database".
(Right mouse button on my project name in the solution explorer.)
-
January 10th, 2008, 12:15 PM
#8
Re: Added a new record in my database, but after rebuild, the record is gone
No problem. Up until now, I had never used the add 'SQL Database' item either.
When you add the db, an app.config file gets created for you (if one already doesn't exist).
Inside the app.config, you find a ConnectionStrings section with the connection for the db. Just modify the path here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|