Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27251

VS 2008 Database problem on multiple queries using the same code

$
0
0
OK i'm learning the vb.net way to access MS Access. But I have run into a snag. As I understand this when I creata a Dataset and then fill it, I have basically filled an array of sorts? What I'm doing is selecting a number from a combobox filled from the Database. then using that as the main criteria for my search for a record, and it always works the first time. but there after some of the data does not change. I am wordering if the dataset should be empted on prior to each access? here is the code I'm using.
Code:

Dim con As New OleDb.OleDbConnection
    Dim dbProvider As String
    Dim ds As New DataSet
    Dim dadapter As OleDbDataAdapter
Sub GetData()
 Try
            dbProvider = "provider=Microsoft.ACE.OLEDB.12.0;data source=..\Hy-Tech Maint2.mdb"


            '"SELECT * FROM tblWorkOrder WHERE WOClosed = False AND DeletedWO = False"
            con.ConnectionString = dbProvider
            con.Open()
            sql = "SELECT * FROM tblMachine WHERE MachineNumber =" & cboMachineNumber.Text
            dadapter = New OleDbDataAdapter(sql, con)
            dadapter.Fill(ds, "Machine")

            'MsgBox("Database is now open")

            con.Close()
            'MsgBox("Database is now closed")

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

                'Start filling in the Fields
        txtManufDate.Text = ds.Tables("Machine").Rows(0).Item(4)
End Sub

Thanks

Viewing all articles
Browse latest Browse all 27251

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>