Hi guys i have this code which insert the data in the textbox

    Dim FilePath As String = "C:\Users\ezekiels\Desktop\New Folder\EBU 6.mdb"
    Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & FilePath & "")
    conn.Open()
    Dim myadapter As New OleDbDataAdapter("SELECT * FROM Table_EBU6", conn)
    Dim dtset As New DataSet
    myadapter.Fill(dtset)
    myadapter.Dispose()

    Dim table As DataTable = dtset.Tables(0)

    Me.Jan_Revenue2.Text = table.Rows(0).Item(1)
    Me.Feb_Revenue2.Text = table.Rows(1).Item(1)
    Me.Mar_Revenue2.Text = table.Rows(2).Item(1)

    conn.close

what if i need to edit the Textbox and the record will update in access?

I use the following methods when I am editing data:

Dim Con as New OleDBConnection("MyStringHere")
Dim da As New OleDBDataAdapter("SELECT * FROM table",Con)
Dim ds As New DataSet

Try
   Con.Open()
   da.Fill(ds,"MyTable")

   ds("MyTable").Rows(0)("ColumName") =  Me.Jan_Revenue2.Text 
   ds("MyTable").Rows(1)("ColumName") =  Me.Feb_Revenue2.Text 
   ds("MyTable").Rows(2)("ColumName") =  Me.Mar_Revenue2.Text 

   da.UpdateCommand = New Data.OleDb.OleDbCommandBuilder(da).GetUpdateCommand
   da.Update(ds.Tables("MyTable"))
Catch ex As Exception
    MsgBox(ex.ToString)
Finally
    Con.Close()
End Try

I got an error in this code

ds("MyTable").Rows(0)("ColumName") = Me.Jan_Revenue2.Text
ds("MyTable").Rows(1)("ColumName") = Me.Feb_Revenue2.Text
ds("MyTable").Rows(2)("ColumName") = Me.Mar_Revenue2.Text 

system.data.dataset' cannot be indexed because it has no default property

the higlighted value is the ds

My appologies. I had typed that code into the editor without a copy of VS handy.

Replace:

ds("MyTable").Rows(0)("ColumnName")

with

ds.Tables("MyTable").Rows(0)("ColumnName")
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.