Link to home
Start Free TrialLog in
Avatar of VBdotnet2005
VBdotnet2005Flag for United States of America

asked on

Fill textboxes

Why do I keep getting error here?  


Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click

        Dim commandstring As String = "SELECT ID, Make, Model, Type, Year FROM  CarTable"
        Dim ConnectionString As String = "provider=microsoft.jet.oledb.4.0;" + "datasource = E:\car.mdb"
        Dim conn As New OleDbConnection(connectionstring)

        Dim dataAdapter As New OleDbDataAdapter

        dataAdapter.SelectCommand = New OleDbCommand(commandstring, conn)

        Dim myDataset As New DataSet

        dataAdapter.Fill(myDataset, "CarTable")        -----------------------ERROR -------------
        datatable = myDataset.Tables("CarTable")
        currRec = 0
        totalRec = datatable.Rows.Count
        FillControls()

        Me.btnForward.Enabled = True
        Me.btnBackWard.Enabled = True




    End Sub


    Private Sub FillControls()

        Me.txtYear.Text = datatable.Rows(currRec)("Year")

        Me.txtMake.Text = datatable.Rows(currRec)("Make")

        Me.txtModel.Text = datatable.Rows(currRec)("Model")

        Me.txtType.Text = datatable.Rows(currRec)("Type")


    End Sub
Avatar of prakash_prk
prakash_prk
Flag of India image

what is the error u got?
Avatar of hagipmc
hagipmc

probably your database is locked and/or read-only..
Maybe some of table column names collide with MS Access reserved words, try change your select command like this:
SELECT [ID], [Make], [Model], [Type], [Year] FROM CarTable
ASKER CERTIFIED SOLUTION
Avatar of maralans
maralans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial