Results 1 to 4 of 4

Thread: Impossible problem VB.Net - Please help

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2020
    Posts
    1

    Impossible problem VB.Net - Please help

    Hi Everyone,

    I am facing problem that I do not understand. I have tried all without any result, so decided to write for your help.

    I am trying to search table in database (Access OleDbConnection)

    I am running code as bellow to find:

    number 7 - Not found
    number 10 - Found
    number 11 (after adding manually into the table) - Not found

    Photos attached.

    I am crazy about it and do not know what to do.
    Code:
     For i = 0 To DataGridView1.Rows.Count - 1
    
                If DataGridView1.Rows(i).Cells(0).Value = 7 Then
    
                    znaleziono = True
    
                Else
    
                    znaleziono = False
    
                End If
    
            Next
    
            If znaleziono = True Then
    
                MsgBox("Znaleziono", vbInformation, "")
    
            Else
    
                MsgBox("Nie znaleziono", vbInformation, "")
    
            End If
    Name:  1.png
Views: 284
Size:  7.3 KBName:  2.png
Views: 314
Size:  7.4 KB
    Last edited by Shaggy Hiker; Aug 30th, 2020 at 10:24 AM. Reason: Added CODE tags.

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

    Re: Impossible problem VB.Net - Please help

    You should never be asking a question here without having debugged your code and if you had debugged this code then the issue would be obvious. Debug your code. Set a breakpoint at the top of the code and step through the code line by line. Once you understand what your code is actually doing, you'll see why it's not doing what you want it to.

  3. #3
    New Member
    Join Date
    Jul 2020
    Posts
    9

    Re: Impossible problem VB.Net - Please help

    I think you should be more elaborative. If am not mistaking, you said you are trying to search a database then why are you iterating through DGV content?

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Impossible problem VB.Net - Please help

    Lol this is a classic mistake, doing a search loop like that. Look very carefully at how that code is structured. Here's a question that should clue you in: Why are you still looping after finding the value you're looking for?
    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

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