Results 1 to 29 of 29

Thread: [RESOLVED] Query returns value from wrong column of the table

Hybrid View

  1. #1
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Query returns value from wrong column of the table

    What is this? :-
    Code:
    MasterBase.MasterBaseQuery
    The problem is probably there.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  2. #2

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

    Re: Query returns value from wrong column of the table

    MasterBase.MasterBaseQuery resides in a module and is used everytime I access the database.

    Code:
            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
                    ListDataSet = New DataSet
                    ListTable = New DataTable
                    ListAdapter = New OleDbDataAdapter(ListCommand)
                    RecordCount = ListAdapter.Fill(ListTable)
                    ListDataSet.Tables.Add(ListTable) 'This Dataset is used for setting comboboxes
    #End Region
                Catch ex As Exception
                    Exception = ex.Message
                    MsgBox(ex.Message + vbLf + vbCrLf + MyError)
                End Try
                MyError = ""
                If MasterBaseConnection.State = ConnectionState.Open Then MasterBaseConnection.Close()
            End Sub
    I sure hope this is not the problem as it is referenced over 100 times. Basically everywhere I need to access the database.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Query returns value from wrong column of the table

    Quote Originally Posted by gwboolean View Post
    MasterBase.MasterBaseQuery resides in a module and is used everytime I access the database.

    Code:
            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
                    ListDataSet = New DataSet
                    ListTable = New DataTable
                    ListAdapter = New OleDbDataAdapter(ListCommand)
                    RecordCount = ListAdapter.Fill(ListTable)
                    ListDataSet.Tables.Add(ListTable) 'This Dataset is used for setting comboboxes
    #End Region
                Catch ex As Exception
                    Exception = ex.Message
                    MsgBox(ex.Message + vbLf + vbCrLf + MyError)
                End Try
                MyError = ""
                If MasterBaseConnection.State = ConnectionState.Open Then MasterBaseConnection.Close()
            End Sub
    I sure hope this is not the problem as it is referenced over 100 times. Basically everywhere I need to access the database.
    You need to debug that method. You ought to have already debugged that method. Step through it line by line. Just before executing the query, execute it directly in the database and see what you get. After executing it in code, examine the DataTable yourself and see what it contains.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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