VBdotnet2005
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.ol edb.4.0;" + "datasource = E:\car.mdb"
Dim conn As New OleDbConnection(connection string)
Dim dataAdapter As New OleDbDataAdapter
dataAdapter.SelectCommand = New OleDbCommand(commandstring , conn)
Dim myDataset As New DataSet
dataAdapter.Fill(myDataset , "CarTable") -----------------------ERR OR -------------
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)("Y ear")
Me.txtMake.Text = datatable.Rows(currRec)("M ake")
Me.txtModel.Text = datatable.Rows(currRec)("M odel")
Me.txtType.Text = datatable.Rows(currRec)("T ype")
End Sub
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.ol
Dim conn As New OleDbConnection(connection
Dim dataAdapter As New OleDbDataAdapter
dataAdapter.SelectCommand = New OleDbCommand(commandstring
Dim myDataset As New DataSet
dataAdapter.Fill(myDataset
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)("Y
Me.txtMake.Text = datatable.Rows(currRec)("M
Me.txtModel.Text = datatable.Rows(currRec)("M
Me.txtType.Text = datatable.Rows(currRec)("T
End Sub
what is the error u got?
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
SELECT [ID], [Make], [Model], [Type], [Year] FROM CarTable
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.