p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Visual Basic 2005 Basics (http://p2p.wrox.com/forumdisplay.php?f=137)
-   -   BindingNavigator Question (http://p2p.wrox.com/showthread.php?t=35774)

wb8bgy December 4th, 2005 07:23 PM

BindingNavigator Question
I am doing the examples in the books and I can't make the BindingNavigator controls delete or add to my data base. I am using an existing Access Table for the data source. When I add or delete records it does show as happening in the current screen. I then do a save, reload, and all the original stuff is back on the screen. It is almost like I am missing something here that makes the table "read Only" or something like that.

Any help would be appreciated.

George javascript:insertsmilie(':)')
Smile :)

Ankur_Verma December 5th, 2005 08:35 AM

1) Tell us if u r working on XP.

2) Post the code u wrote to perform the task, there may be something wrong with that.

Ankur Verma

wb8bgy December 5th, 2005 06:05 PM

Yes, I am using Windows XP Professional with Service Pack 2.

The code I am using to save data is:

Private Sub ProjectsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProjectsBindingNavigatorSaveItem.Click

If Me.Validate Then
            Me.ProjectsTableAdapter.Update(Me.MKADataSet.proje cts)
            System.Windows.Forms.MessageBox.Show(Me, "Validation errors occurred.", _
            "Save", System.Windows.Forms.MessageBoxButtons.OK, _
        End If
    End Sub

Hope that helps. Have been trying to find an example of working code but no luck so far.

George Race

wb8bgy December 5th, 2005 08:27 PM

I tried something from the examples:

            Me.ProjectsTableAdapter.Update(Me.MKADataSet.proje cts)
            MsgBox("Update successful")

        Catch ex As Exception
            MsgBox("Update failed")
        End Try

Got the same results with Update Successful each time. Still When I reopen the database no changes were saved.

Ankur_Verma December 6th, 2005 02:34 AM

George, your code is fine and should work. Just make sure that the mdb file is not readonly.
You may even find that you are not able to remove the "Read Only" attribute of the mdb file. To be able to remove the readonly attribute, you need to have proper rights specified in the file's and its folder's ACLs.
Like if you copy the file in a folder on which your user has enough credentials (like "User Name"\My Documents), you will be able to remove the readonly attribute. Or you can modify the ACLs and then remove the readonly attribute.
Such issues are quite common in XP, though, and somewhat conform to the fact that XP has better inbuilt security infrastructure.


wb8bgy December 6th, 2005 09:59 PM

Hi Ankur:

Boy, I am just not having any luck at all with this situation. The files are not read only and I am the administrator of the system so have full rights in all directories. I have noticed one thing that may be important. When I open the Database Explorer my MKA.mdb file has a small red X in the lower right corner of the symbol. If I check on refresh the Red X goes away and it looks like there may be a black key in place of the red X.

Not sure if this has any bearing on the problem that I am having. No matter what I do, I just cant seem to save any changes that I make to the database.

When I use the "try" example I always get back "Update successful" but again there is never a change in the database. Does not matter if I add records or delete records, the database does not seem to change.

What next?

I am really getting frustrated with what should be a simple procedure.


Ankur_Verma December 7th, 2005 12:45 AM

That small red X shows disconnection and as soon as u refresh or expend the node it disappears indicating that the connection is established. This small x doesnt matter 'cause it disappears, whould have mattered if it werent.

We all usually work with Administrator's privilages on our systems, this problem is quite common still, if you are working on XP. So I'll again ask you to see the 'file attributes' of your mdb file in windows explorer or cmd and make sure that 'read only' is not checked.

Ankur Verma

wb8bgy December 9th, 2005 02:49 PM

Thanks, and the file is definately not Read Only!

Seems like this should be easy but I can't make any of the examples delete or save data using the BindingNavigator controls.

Can you email me an attachment containing an example of one that works?



Ankur_Verma December 9th, 2005 05:15 PM

Sent you one.

wb8bgy December 9th, 2005 10:12 PM

Hi Ankur:
Well you did it! I now have the code working. The example you sent would not work in the location I put it. Could not find the .mdb file. In looking at the error I saw that your file was pointing to a different location. So....I opened the "app.config" file and inserted my address string to the file. It worked perfectly after that!

That got me thinking so I went and looked at the "app.config" file for my program directory. It was marked: ....[DataDirectory] MKA.mdb (MKA.mdb is my Access Data File) I pasted in place of "DataDirectory" the actual path to my mdb file and everything started to work!

When I imported the .mdb file to the project, I wonded if some kind of a problem occured and it actually left the "DataDirectory" path pointing back to my original location before the import. That would explain why I saw changes in the "real" directory in my Access Program as I was playing around with the Visual Basic version that I am trying to convert/write.

Anyway Ankur your code file led me to the answer. I am sure I will have more questions as I proceed with this very complicated conversion from Access to VB. It will be a great learning experience for me and I hope you don't mind me coming back to you often for help and answers.

Thank you so much for the help and sticking in there with me to the end.

George Race

All times are GMT -4. The time now is 10:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.