Results 1 to 8 of 8

Thread: [RESOLVED] Find the DataBinding Error... Or Where is Waldo?

  1. #1

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

    Resolved [RESOLVED] Find the DataBinding Error... Or Where is Waldo?

    I had thought that the BinDebug, (|DataDirectory|) would/had cleared up this databinding issue I have been having. I had thought they were related, but they clearly are not.

    Anyway, I started with a clean project and rebuilt everything in it and am still getting this same error when attempting to open and display a record.

    Cannot bind to the property or column ColumnName on the dataSource. Parameter name: dataMember

    The complete process is defined below. I have been unable to detect any errors in the query and am sure that it is executing opening the record.

    Code:
                    GetStaffRecord(StaffID)
                    lblFilePath.Text = GetDirectory(MyDirectory).ToString
                    If MyState = "Edit" Then SetState("Edit") Else SetState("View")
                    BindControls()
    GetStaffRecord() connects to the database and opens a specific record.

    Code:
        Private Function GetStaffRecord(ByVal StaffID As String) As Object
            'Add Parameters
            MasterBase.AddParam("@recno", StaffID)
    #Region "Establish connection And execute Query"
            Try
                Dim RecordCount = 0
                MasterBase.Exception = ""
                MasterBase.MasterBaseQuery("SELECT colStaffID,colFirst,colMiddle,colLast,colFull,colDept,colTitle,colDetail," &
                                           "colFilePath,colStart,colEnd,colActive,colObsolete " &
                                           "FROM sitStaffMaster " &
                                           "WHERE colStaffID = @recno")
            Catch ex As Exception
                MasterBase.Exception = ex.Message
                MsgBox("Staff List query failed." + vbLf + ex.Message)
                Me.Close()
                staffList.Show()
            End Try
            Return StaffID
    #End Region
        End Function
    The GetDirectory() routine does indeed provide the proper value for lblFilePath. Additionally, I do not believe that there is anything in SetState() that is at all related to databinding properties, except for those of a combobox.

    Code:
            cboOwner.DataSource = DeptBindingSource
            cboOwner.ValueMember = "colType"
            cboOwner.DisplayMember = "colType"
    The exception is thrown in the routine, BindControls() at the first line. I have done some testing to suggest that this would apply to every column.

    Code:
        Private Sub BindControls()
            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
    All of my SQL queries use parameters and are run through the following two routines.

    Code:
        Public Class MasterBaseConn
    #Region "MasterBase Connection Parameters"
            Public MasterBaseConnection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=MasterBase3.0.accdb;") 'Database Connection
            Public ListCommand As New OleDbCommand
            Public ListAdapter As OleDbDataAdapter
            Public ListTable As DataTable
            Public Params As New List(Of OleDbParameter)
            Public Exception As String
            'Dim ManageChange As MasterBaseConn
    #End Region
            Public Sub MasterBaseQuery(SetQuery As String)
                RecordCount = 0
                Exception = ""
                Try
    #Region "Open Connection/Load Table"
                    MasterBaseConnection.Open() 'Open connection
                    ListCommand = New OleDbCommand(SetQuery, MasterBaseConnection) 'Database Command
                    Params.ForEach(Sub(p) ListCommand.Parameters.Add(p)) 'Load params into command
                    Params.Clear() 'Clear params list
                    ListTable = New DataTable
                    ListAdapter = New OleDbDataAdapter(ListCommand)
                    RecordCount = ListAdapter.Fill(ListTable)
    #End Region
                Catch ex As Exception
                    Exception = ex.Message
                    MsgBox(ex.Message + vbLf + "Query failed to execute.")
                End Try
                If MasterBaseConnection.State = ConnectionState.Open Then MasterBaseConnection.Close()
            End Sub
            Public Sub AddParam(Name As String, Value As Object)
                Dim NewParam As New OleDbParameter(Name, Value)
                Params.Add(NewParam)
            End Sub
        End Class
    Additionally, here is the table being used.

    Name:  Screen1.jpg
Views: 176
Size:  32.8 KB
    I have used the MasterBasseConn Class without any issues for quite some time now and am unable to find any reason to believe this to be causing me the problem I am having. If my query is running clean, and I am certain that it is, then this should not be the issue.

    While I do have a tendency to have coding errors that I never seem to be able to see, I am pretty sure that my code is clean (I really hate saying that because I know it never is).

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Find the DataBinding Error... Or Where is Waldo?

    So did you put a breakpoint on that line and actually look at MasterBase.ListTable to see whether it actually had a column named "colStaffID"? You seem to be assuming that it does but the error message is telling you that it doesn't. The obvious next step is to actually look rather than assume. I would guess that you'll find that it doesn't. I would guess that that would be the case because you haven't actually executed the code to populate that table at that stage. You should have already checked all that because that's what VS has a debugger for.

    It seems like you just don't know how to debug code. I suggest that you stop what you're doing and learn how to use the debugger. Doing so will save you a lot of time and aggravation. At the very least, learn how to use breakpoints, step through code and use the Autos, Locals, watch and Immediate windows. You could almost certainly have resolved this issue in a few minutes using just those features. A couple of breakpoints alone would have told you whether you're binding the DataTable before populating it.

  3. #3

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

    Re: Find the DataBinding Error... Or Where is Waldo?

    It seems like you just don't know how to debug code
    Ya think?

    I suggest that you stop what you're doing and learn how to use the debugger.
    What you are saying is that I should not be doing this kind of stuff unless I am a trained and experienced developer. That is very bad advice.

    Doing so will save you a lot of time and aggravation.
    No more than the aggravation of bad advice.

    So let's just delve into the issue and perhaps we can help me see the light!

    Did you put a breakpoint on that line and actually look at the MasterBase.ListTable to see whether it actually had a column named "colStaffID"
    No, I didn't. What I did was put a break point slightly ahead of that and then stepped through until I got to the exception. Many, many, many times. At that point my capabilities become limited and I do not clearly understand everything that I see and read when an error like this occurs.

    Did you actually look at MasterBase.ListTable to see whether it actually has a column named "colStaffID"?
    Now here is where you can be helpful. It is not clear to me how I would actually look at MasterBase.ListTable. I know how to look at the table from the datasource, from the designer and from the server explorer. So where would I look to actually see MasterBase.ListTable?

    You seem to be assuming that it does but the error message is telling you that it doesn't.
    The only thing I am assuming is that I did not make a code mistake that is driving this whole thing. And that is always a shakey assumption. Now as soon as I have an idea how I might be able to view MasterBase.ListTable I will be happy to. However, I believe that it would be more fruitful to understand why MasterBase.ListTable has something different than the column noted, as well as all the other columns.

    I would guess that that would be the case because you haven't actually executed the code to populate that table at that stage.
    OK, let's assume that to be true. So you appear to be telling me that MasterBase.ListTable is not populated. The question should then be, why is MasterBase.ListTable not populated? I don't know and that is why I am here to ask if someone does know.

    I have done all of the things I believe to be necessary for this operation to be successful. Obviously, that is not the case.

    So, if you know what I have left out of this process/operation that has caused it to fail, could you please just say what it is instead of pushing some rather bad advice about how I should not be doing something like this until I am sufficiently trained and experienced?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Find the DataBinding Error... Or Where is Waldo?

    Quote Originally Posted by gwboolean View Post
    What you are saying is that I should not be doing this kind of stuff unless I am a trained and experienced developer. That is very bad advice.
    Except that's not what I said but you're too busy whining to listen to someone who is trained and experienced and learn something to help yourself. I'm done here.

  5. #5

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

    Re: Find the DataBinding Error... Or Where is Waldo?

    Except that's not what I said
    Not verbatim. But your intent was clear.

    you're too busy whining to listen to someone who is trained and experienced
    I applaud your training and experience. Perhaps you might consider offering up some wisdom from that training and experience. But you are too busy whining about how I should be a fully trained and experienced developer before doing something that is just a hobby to me.

    I am done here!
    Considering that the only thing that you offered is criticism and a supercilious attitude, in tandem with an unwillingness to offer any help, whatsoever, I would say that you were done before you ever started.

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Find the DataBinding Error... Or Where is Waldo?

    Just a suggestion - and sometimes the path I follow when building up new efforts in code.

    Start with a few fields - even a single field. I always like to see that the plumbing works, especially since you are dealing with a "service app" like SQL running on your PC or network.

    Once you see the I/O in action, adding fields is a breeze. If you add them all at once and it breaks, then once again, back down and put a few fields in.

    You have VB, .Net, databinding (MS hack, imo, lol!), TCPIP connectivity to SQL with all the network and authentication issues that come with it. Where it's broken, nobody knows!

    -------------------------------------

    TL;DR - remove the field in question from the query and the binding code. Does it work?

    Or try to get value from jmc - I know he can be a tall order - and realize that he's the number #1 expert in the problem you are having and work with him. Smaller posts - offer less words - react singularly to his requests...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7

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

    Re: Find the DataBinding Error... Or Where is Waldo?

    Or try to get value from jmc
    That appears to be a ship that has long ago sailed. I have, numerous times, attempted to follow his vague, and sometimes contradictory, suggestions that are always accompanied by his attitude of throwing pearls before swine. He may well be an expert and be quite knowledgeable, but the evidence is rather slim, considering the quality of his offerings over time.

    The answer to any of my questions, or anyone else's for that matter, fall under a breakdown of a process. The process I am currently having a problem with should be a simple process with a limited number of inputs and outputs. Simply put, a process can be defined as a single line, usually with an end point, with some number of curved lines depicting inputs/outputs. If one is truly interested in assisting another with a process then one should present their knowledge with respect to the process and what/how the process is affected by individual inputs/outputs, or combinations of inputs/outputs. JMC, for all his claimed knowledge, appears to not even grasp the concept of process and how to construct/deconstruct a process.

    So here is the process currently under discussion.

    A table exists and a process is defined to access, modify, add, and delete data for this table. The existing table is the process. The access, modify, etc. are the inputs/outputs for the process.

    Here is the process as I understand it. I have a database (call that your process line)

    1. I begin the process by connecting to the database.
    2. I query the database
    3. I display the data obtained from the database.
    4. I modify the data (if desired)
    5. I save the date (if desired)
    6. I end the process

    So, this is the process under consideration:

    Code:
                    GetStaffRecord(StaffID) 'queries MasterBase.FileTable for record with colStaffID value mactching the StaffID value.
                    lblFilePath.Text = GetDirectory(MyDirectory).ToString
                    If MyState = "Edit" Then SetState("Edit") Else SetState("View")
                    BindControls()
    Simply put:

    1. Connect to the database
    2. query the database for the table/records of interest
    3. display query results and allow changes to be made.
    4. save modifications to the database/table.
    5. End the process by closing the database.

    I believe I thoroughly explained each component of this process, and what it does, in the original post. Clearly, based on the results of running the process, there is something missing, or incorrect in the process.
    As far as I have been able to understand, there is nothing wrong with the process.

    I have stepped through this process many, many, many times and while I am literate enough to read all of the detail that I can observe, I do not fully understand what it is telling me (sometimes I have no understanding at all). Additionally, the only suggestion I am offered, by our esteemed expert, is to tell me that I am a simpleton because I did not view the MasterBase.ListTable that was created in the connection/query part of the process. Now I would be as happy as a pig eating slop to do this, but I have no idea how to achieve this and our esteemed expert appears to be unable or unwilling to offer any assistance of how to achieve this noble end. Thus leaving me with what I usually end up doing, which is poking, tinkering and stepping through each line of code until, at some point, I can finally see what the issue is. A rather inefficient and poor approach to learning anything at all about anything at all.

    Keep in mind that I am NOT a developer and do not wish to be one. I am merely a 73 year old hobbyist (who is clearly cantankerous), with an interest in certain aspects of database design/usage, and NO desire to become an expert. Besides, this sytem is supposed to be designed such that one should NOT have to be an expert to understand and use the system.

    Quite frankly, I am very disappointed with how these developer forums work. I participated, for years, in engineering forums as an expert in chemical engineering as applied to developing and marketing pharmaceutical/Medical devices. I have to say that the manner in which JMC approaches this is completely unprofessional and indicates a lack of grounding in process, design, construction, or any kind of engineering concepts. Is seems that he is unaware that Computer Science is a function of engineering.

    Anyway SZ, Could you perhaps have a look at the process as defined, and maybe suggest to me what might be missing from the process or, alternatively, how the process is being incorrectly applied?
    Last edited by gwboolean; Jan 4th, 2022 at 01:49 PM.

  8. #8

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

    Re: Find the DataBinding Error... Or Where is Waldo?

    OK, I finally resolved the issue. It turns out that the resolution was simply to reverse two of the steps in the process described in above post, i.e.

    Code:
                    GetStaffRecord(StaffID) 'queries MasterBase.FileTable for record with colStaffID value mactching the StaffID value.
                    lblFilePath.Text = GetDirectory(MyDirectory).ToString 'Queries settings table to obtain the file path for relevant content/files.
    The above sequence causes the error. The below sequence allows the process to successfully execute.

    Code:
                    lblFilePath.Text = GetDirectory(MyDirectory).ToString 'Queries settings table to obtain the file path for relevant content/files.
                    GetStaffRecord(StaffID) 'queries MasterBase.FileTable for record with colStaffID value mactching the StaffID value.
    This is how one would properly and professionally respond to a request for assistance with an issue. At least in the old days on engineering forums.

    At any rate, I would like to know why I should have been able to easily see this by endlessly looking at the debugger. While the resolution is simple, it is not obvious at all.

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