Hello, i try to develop some application for inventory and transaction using VB.Net with database access
i have a problem with query result, it looks like not using newest database when application already run.
for example :
i have MS access table like this
ID CustomerName
1 John
2 Doe

then i run my application and do search by ID, then i add new row directly using MS access to the table
3 John Doe

then i search ID = 3 , the result is not found. Help me please , thanks

Here is my codes.

    Public Sub ConnOpen()
        conn = New OleDb.OleDbConnection
        conn.ConnectionString = dbProvider & dbSource
        conn.Open()
    End Sub

    Public Sub ConnClose()
        conn.Close()
    End Sub

    Public Function GetData(query As String, tbl As String)
        ConnOpen()
        Dim da = New OleDb.OleDbDataAdapter(query, conn)
        Dim ds As New DataSet
        da.Fill(ds, tbl)
        ConnClose()
        Return ds
    End Function

    Public Function FindBarang(vcode As String)

        Dim query As String
        query = "SELECT * FROM "
        query &= "People "
        query &= "WHERE ID = " & vcode

        Dim data As DataSet = GetData(query, "FPeople")

        Return data.Tables("FPeople").Rows
    End Function

Recommended Answers

All 2 Replies

Close your connection and reopen it after adding/editing database directly from Access.

thank you, i just realize it that i made a mistake. i edit the database which not in debug folder. that's why it not using newest database
thanks sir for your reply, it really help me a lot. thanks once again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.