database question RE: cjards post titled "Changes are gone when I restart the app"

thirteentwenty

Well-known member
Joined
Oct 9, 2008
Messages
80
Location
Honolulu
Programming Experience
Beginner
database question RE: cjards post titled "Changes are gone when I restart the app"

So I just got through reading this post as it addressed a question that I had, and it did answer, cjard, thank you for that, but... there's always a but...

I just tried with an accdb file and it doesn't work as described (read: with the mdb file). Maybe I'm doing something, I'm not sure... but vs2005 didn't give me the option to copy the file as it did with other projects that I've tried.

Does anyone have any suggestions, pointers/tips/clues/etc...?

anyways thanks for the advice =)

heh... maybe I should explain whats happening...

the accdb file appears dimmed (when "Show all files" is selected) and I do not have the option to "Copy if newer" or "Copy Always" in the Properties window for the file. And when adding data source to the project I didn't get the dialog asking to copy to the output directory...

I'm going to feel like a total ass if I left out some crucial step... =(
 
Is the file actually part of your project? if you right click it, do you get the option to "Include In Project" ?

I'm currently reading up on whether ACCDB files are simply file based databases like MDBs are..

How did this db come to be a part of your project(or, "not part of it" as it may be)
 
If by getting the "Include in Project" in the context menu means that it is part of the project, then no, it is not.

the accdb file was created with msaccess 2007 and is the default format. When adding the datasource one has to choose "other" then specify that it is to use the Office 12 driver.

As far as how I got it to be a part of (or not), I followed the steps as described in the DW2 link, just modified slightly to accommodate for the difference in file types (read my access database vs. the northwind).

Click "Add New Data Source"
Follow Wizard

Question: Would doing a clean build then Build Project make a difference? I haven't done so because I haven't done so yet, All I've done is hit the F5 key to debug as instructed...

Cjard, by the way thank you for your guidance in my previous posts, I can imagine what goes through your head when someone wants to do database work programmatically as I did. It was just an exercise for me, I'm _trying_ to get it done right by taking your advise and going through the links in your sig.Which brought to my attention that one of them (DDS: The DataSet Designer Surface) is broken, I tried to PM you this but it seems that you're so popular that your mailbox is full =D
 
Last edited:
If by getting the "Include in Project" in the context menu means that it is part of the project, then no, it is not.

the accdb file was created with msaccess 2007 and is the default format. When adding the datasource one has to choose "other" then specify that it is to use the Office 12 driver.
Hmm.. I think i'm going to have to install 2007 to test this out fully, but it may be that because 2007 came along after 2005, the integration is slightly different.. VS might not realise that this is a file based database system.. It depends on how the conenction string is built, i suppose.

Does your connection string contain a direct reference to the absolute path of the accdb file?

Did you, at any point of the wizard see a dialog asking whether to copy the db into the project blah blah press F1 for information on controlling this behavior ?


Question: Would doing a clean build then Build Project make a difference? I haven't done so because I haven't done so yet, All I've done is hit the F5 key to debug as instructed...
You can try it, but I don't think so.. It sounds like VS isnt aware that this DB is part of your project. THe most intersting thing to know at this time would be how you set up the connection using the office 12 driver



I can imagine what goes through your head when someone wants to do database work programmatically as I did.
Well.. it's all programmatic, it just a matter of what entity writes the code :)

It was just an exercise for me, I'm _trying_ to get it done right by taking your advise and going through the links in your sig.Which brought to my attention that one of them (DDS: The DataSet Designer Surface) is broken,
I know.. I've run out of space in my signature text to make the link work, and relative links don't work here. I'll have a go at fixing it one day.. and i'll ponder on how jmc managed to get so much text into his sig. Mayube mods have a higher limit

I tried to PM you this but it seems that you're so popular that your mailbox is full =D
I leave it full to stop people messaging me. You wouldnt believe the amount of personal tuition is sought. Public forum is so much better for getting complete, speedy answers. Everyone I know complains at the time it takes me to respond to emails, sms etc
 
I know.. I've run out of space in my signature text to make the link work, and relative links don't work here. I'll have a go at fixing it one day.. and i'll ponder on how jmc managed to get so much text into his sig. Mayube mods have a higher limit
Last time I changed my sig I was going at the limit around 900 chars by just a few chars, that includes markup chars so you have to be clever about that. I see your sig currently is about same length as mine. jmc doubles that and more, perhaps he got a better deal or perhaps the limit was changed.
I leave it full to stop people messaging me. You wouldnt believe the amount of personal tuition is sought. Public forum is so much better for getting complete, speedy answers. Everyone I know complains at the time it takes me to respond to emails, sms etc
Through the years here I have received less than 10 such requests in total (it's true!), in those cases I have just replied with link to this sticky in Forums General Info: http://www.vbdotnetforums.com/vb-ne.../13769-please-do-not-pm-programming-help.html
You can of course choose to disable forum PM too.
 
Hmm.. I think i'm going to have to install 2007 to test this out fully, but it may be that because 2007 came along after 2005, the integration is slightly different.. VS might not realise that this is a file based database system.. It depends on how the conenction string is built, i suppose.

Does your connection string contain a direct reference to the absolute path of the accdb file?
I've uploaded a psd file (i was to lazy to separate the layers, if you want me to I'll go a head and do that...) which contains the steps of the wizard.

Link to PSD file.

Did you, at any point of the wizard see a dialog asking whether to copy the db into the project blah blah press F1 for information on controlling this behavior ?

Nope, which is why its puzzling to me, I do get that message if I use an .mdb file.

You can try it, but I don't think so.. It sounds like VS isnt aware that this DB is part of your project. THe most intersting thing to know at this time would be how you set up the connection using the office 12 driver

I'm going to give that a try, and I'll go and see if there are any updates that I've missed.

As far as the connection goes I found this post on the MSDN site detailing the steps (those are the screenshots that I linked to above)

I leave it full to stop people messaging me. You wouldnt believe the amount of personal tuition is sought. Public forum is so much better for getting complete, speedy answers. Everyone I know complains at the time it takes me to respond to emails, sms etc

I think I could, lol I've thought about PM'ing some people here to ask for advice and what not, but like you said, the public forum is the better place to get advice as (imo) we get speedier responses, and more times than not one will get multiple suggestions to resolve an issue.
 
Last edited:
Nope, which is why its puzzling to me, I do get that message if I use an .mdb file.
Could the fact that youre selecting a file that is already in a child directory of your solution (i.e. the debug folder) be confusing the logic that does the checking?

Copy the accdb to the desktop and try include it in your project

If I can find a trial copy of Office2007 I'll be able to do the same, but I'm very busy atm.. Might be a few days
 
Could the fact that youre selecting a file that is already in a child directory of your solution (i.e. the debug folder) be confusing the logic that does the checking?

Copy the accdb to the desktop and try include it in your project

If I can find a trial copy of Office2007 I'll be able to do the same, but I'm very busy atm.. Might be a few days

Good morning cjard!

No rush... I'll give that a try and see how it goes.
 
I think the copy if newer option is available for any file type. I mean, I can choose the option of a JPG, PNG, even code files. Just set the Build action to "Content" to make sure VS knows what to do with the file and you should be good to go... And if the connection string was set correctly and it is translated for the debug/release compilations correctly, I would think VS does know what the file is.

In any case, I am pretty sure you could use a plain text file as database (and even give it a custom extension), set the Build action to "Content" and Copy to output directory to "Copy if newer" and the text file will work as a database file just as an Access DB will. The compilation version will be replaced only when you manually change the project version. I've done something similar once for a license system (I tried on Vista and switched the file to the Common app files directory anyway).

One more thing, right click on the file and click the "Properties" item. I have both the Solution explorer and the properties pane in tabs on over the other and this helps to make sure I have the right file in the property screen...
 
Last edited:
@Stonkie, that would be part of the problem... I don't get that option in the properties window of the accdb file as it's "not part of the project" for some reason.
 
In the screenshot provided by Cjard, there are two files. On is semi-transparent under the "bin/debug" directory and on is in normal state just under the project (the second circled file, the one that is selected). This is the file the option must be set on. It is the copy of the file associated to the project which gets copied to the output directory (the dimmed one gets overwritten by it, this is the one you access from your application). Do you see this normal file at the same level as your source code files in the solution explorer?

Visual Basic .NET Forums
 
Do you see this normal file at the same level as your source code files in the solution explorer?

No, both are dimmed when the "Show All Files" option is selected.

I haven't had a chance to work with this project today, but will later this afternoon, I'll be running an update just in case there was a patch or something I may have missed to allow the .accdb (Access 2007 database) extension to work with VS2005 properly.
 
Can you provide a db file that gives the same problem and isn't too big so we can try adding it ourselves? Like a trimmed down version of yours.
 
Sure thing!

None of the information in it is 'sensitive'

.zip contents
  1. uli.accdb
 

Attachments

  • accdb.zip
    15.6 KB · Views: 20
Copy the accdb to the desktop and try include it in your project

Tried, no dice...
No luck after running updates either...

Things I tried
  • Ran updates etc (no dice)
  • moved accdb file (on existing project) project failed to locate accdb file would no debug
  • created new project with accdb file on desktop, (did not ask to create copy)

It may just not work with the wizard...
Although if I hand type everything I could get it to work... but then what would the point of going through all those walkthroughs be?
 
Back
Top