Results 1 to 15 of 15

Thread: [RESOLVED] |DataDirectory| and BindDebug Blues

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    703

    Resolved [RESOLVED] |DataDirectory| and BindDebug Blues

    This whole thing with |DataDirectory| is a total PIA. I have tried and tried to get this right with little success. Additionally, all of the information I have found on it really doesn't ever fix the problem.

    I like to keep my database in the bin\debug folder of a given project. So whenever I want to create a dataset (either by code or by wizard), the connection string in the project properties folder always shows

    Code:
    DataInformation|DataDirectory|\bin\debug
    As soon as I use the dataset I get an error explaining that it cannot find the database in \bin\debug\bin\debug. Which is not surprising considering there is no bin\debug\bin\debug. It has been suggested that simply removing the \bin\debug from the correction string will remediate the problem... Not so much. Now when I want to bind the data to controls a new problem rears it's ugly head. telling me that

    Code:
    System.ArgumentException: 'Cannot bind to the property or column colSTaffID on the DataSource.
    Parameter name: dataMember'
    Now I cannot say 100% that this problem is caused by what I call BinDebug Blues (catchy name), but I am pretty sure it is related to that, since it I almost never see this error under other circumstances. I have been able to find out that |DataDirectory| is some kind of Macro in the appDomain. I know what a Macro is, but I have now idea what effect that has. There are instructions to make changes... My previous attempts to implement these suggestions that I find usually end up in a disaster that completely destroys everything I have done.

    So, for a change, I thought it might be a good idea to reflect with those who might fully understand what is going on prior to destroying everything.

    Personally, I would just like to have the full path defined and placed into the connection string and do away with |DataDirectory|, but that hasn't worked out so well for me either.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: |DataDirectory| and BindDebug Blues

    System.ArgumentException: 'Cannot bind to the property or column colSTaffID on the DataSource.
    Parameter name: dataMember'
    Would help to see the relevant code and the line that throws the error. It seems to be saying the Datasource doesn't contain a property or column named colSTaffID. Or the DataMember doesn't. Not sure.

    I've found using DataDirectory very useful when deploying the program. It just basically says, use the database thats in the folder the program is ran from. But if you've added the database to the project and selected copy if newer. Then the actual database that needs to be used when designing your dataset is in the program folder. I never liked that and most of the time I didn't add the database to the application and just use a full path until I was read to deploy the program.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    703

    Re: |DataDirectory| and BindDebug Blues

    I would like to see...
    Sure!

    The error occurs when executing the following routine. The error occurs when attempting to bind the first column.

    Code:
        Private Sub BindControls()
            Dim MasterBaseBindingSource As New BindingSource
            MasterBaseBindingSource.DataSource = MasterBase
            lblStaffID.DataBindings.Add("Text", MasterBase.ListTable, "colSTaffID")
            txtFirst.DataBindings.Add("Text", MasterBase.ListTable, "colFirst")
            txtMiddle.DataBindings.Add("Text", MasterBase.ListTable, "colMiddle")
            txtLast.DataBindings.Add("Text", MasterBase.ListTable, "colLast")
            lblFullName.DataBindings.Add("Text", MasterBase.ListTable, "colFull")
            cboOwner.DataBindings.Add("Text", MasterBase.ListTable, "colDept")
            txtTitle.DataBindings.Add("Text", MasterBase.ListTable, "colTitle")
            txtDetail.DataBindings.Add("Text", MasterBase.ListTable, "colDetail")
            lblFilePath.DataBindings.Add("Text", MasterBase.ListTable, "colFilePath")
            lblStart.DataBindings.Add("Text", MasterBase.ListTable, "colStart")
            txtEnd.DataBindings.Add("text", MasterBase.ListTable, "colEnd")
            rdoActive.DataBindings.Add("checked", MasterBase.ListTable, "colActive", True, DataSourceUpdateMode.OnValidation, CheckState.Indeterminate)
            rdoObsolete.DataBindings.Add("checked", MasterBase.ListTable, "colObsolete", True, DataSourceUpdateMode.OnValidation, CheckState.Indeterminate)
        End Sub
    I am unable to understand why this could even be a problem.

    No one should be accessing and using an original database (whatever kind of database they are using). The database used by any application should/must be a copy of the original that is placed in a location that is relevant to the application. What kind of mickey mouse crap process would be setup to operate any other way?

    Anyway, why is it that if I just input the path I want to use and eliminate the |DataDirectory| that I end up with issues?

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    703

    Re: |DataDirectory| and BindDebug Blues

    I have been forced to conclude that the BinDebug problem is not related to the error under discussion. I still don't like it, but it looks to me that they are unrelated.

    That being the case, the error below no longer makes any sense to me and I have no idea where to look to find and fix the issue.

    An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll
    Cannot bind to the property or column colSTaffID on the DataSource.

  5. #5
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: |DataDirectory| and BindDebug Blues

    Not sure why you created a bindingsource, your not using it.

    Here's a simple example of using a bindingsource,

    Code:
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim ds As New BooksDBDataSet
            Dim ta As New BooksDBDataSetTableAdapters.BooksTableAdapter
            ta.Fill(ds.Books)
            Dim bs As New BindingSource
    
            bs.DataSource = ds
            bs.DataMember = "Books"
    
            Me.Label1.DataBindings.Add("Text", bs, "BookId")
    
        End Sub

  6. #6
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: |DataDirectory| and BindDebug Blues

    Can you see what this returns?

    Code:
    AppDomain.CurrentDomain.GetData("DataDirectory")
    Because of how its done internally.

  7. #7
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: |DataDirectory| and BindDebug Blues

    Also, I sould mention you would get that error if "colStaffIds" was not the name of a field in MasterBase.ListTable DataTable. That does seem the most likely problem.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    703

    Re: |DataDirectory| and BindDebug Blues

    Well crap. I lost my resonse.

    Karen,

    I would run that, but I do not know where you would place that line of code. Additionally, that is very similar to a way to define the |DataDirectory| that I didn't try because I figure I could only make things worse.

    Wes,

    I was unable to find the "colStaffids" you mentioned. Could you perhaps indicate where I might look for that?

  9. #9
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: |DataDirectory| and BindDebug Blues

    I was unable to find the "colStaffids" you mentioned. Could you perhaps indicate where I might look for that?
    Well that's just a typo, it should have been colStaffId

    Code:
    lblStaffID.DataBindings.Add("Text", MasterBase.ListTable, "colSTaffID")
    Could you perhaps indicate where I might look for that?
    Open your dataset and check if the datatable ListTable has a field with that name.


    Edit: Actually a more correct term would be DataColumn

    Open your dataset and check if the datatable ListTable has a Datacolumn with that name.


    If your not going to be using a BindingSource and just use your typed dataset. Then if colStaffId does exist in the MasterBase.ListTable datatable you could just use IntelliSense and do this,

    Code:
    lblStaffID.DataBindings.Add("Text", MasterBase.ListTable, MasterBase.ListTable.colStaffId.ColumnName)
    Last edited by wes4dbt; Dec 31st, 2021 at 09:00 PM.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    703

    Re: |DataDirectory| and BindDebug Blues

    The same error will occur for all of the columns in the routine. ColStaffID just happens to be the first. I still have the feeling that someing isn't right with the dataset.

    I tried the code as you suggested, and it errored claiming that colStaffID is not a member of the table.

  11. #11
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: |DataDirectory| and BindDebug Blues

    I assume you've opened the dataset and verified those are the correct datacolumn names. If so then you may have a corrupted dataset file. I'd create a new one.

  12. #12
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: |DataDirectory| and BindDebug Blues

    Let me walk that back.

    First I'd delete the datatable from the dataset, save the changes and then add the datatable back to the dataset. Verify the datacolumn names and test. If it still errors, I don't know what else is left but to delete the dataset and recreate it.

    Now, I don't how or where the MasterBase dataset is created so I have limited knowledge. But I have had corrupted datasets and had to redo them.

  13. #13
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: |DataDirectory| and BindDebug Blues

    Quote Originally Posted by gwboolean View Post
    Well crap. I lost my resonse.

    Karen,

    I would run that, but I do not know where you would place that line of code. Additionally, that is very similar to a way to define the |DataDirectory| that I didn't try because I figure I could only make things worse.
    You can place the code where ever makes sense, like Shown event. In regards to make things worst, this is why it's important to use version control such as GitHub, learn about stashes, branches, squash and revert.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    703

    Re: |DataDirectory| and BindDebug Blues

    You can place the code where ever makes sense
    Cool. I now need to go back and find that line of code I saw that allows you to define what |DataDirectory| is, (what I call BinDebug).

    Having said that, I have reinstalled all of the software I use, and even completely rewrote the code used. The problem with the binding is still there. I still believe that this has something to do with BinDebug, but no evidence to support that belief.

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    703

    Re: |DataDirectory| and BindDebug Blues

    OK, I just put this into the Load event.

    Code:
            AppDomain.CurrentDomain.SetData("DataDirectory", "C:\SiTech\Development\SiTechSolution\MasterBaseAccess\Bin\Debug\MasterBase3.0.accdb")
    That did eliminate BinDebug as well as the binding issue I was having with the BindControls() routine.

    Nyah, Nyah!!!! (That's my victory dance/song). Thanks for the help!!!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width