How to programmatically set a data cell of database in VB.Net?
- by manuel
I have a Microsoft Access database file connected to VB.NET.
In the database table, I have a 'No.' and a 'Status' column.
Then I have a textbox where I can input an integer.
I also have a button, which will change the data cell in 'Status' where 'No.' = textbox.Text(), when I click it.
Let's say I want the 'Status' cell to be changed to "Low".
What codes should I put in the button_Click event handler?
Here is the codes I used to retrieve and display the database table.
Public Class theForm
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim daTitles As OleDb.OleDbDataAdapter
Private Sub theForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|\db1.mdb"
con.Open()
daTitles = New OleDb.OleDbDataAdapter("SELECT * FROM Titles", con)
daTitles.Fill(ds, "Titles")
DataGridView1.DataSource = ds.Tables("Titles")
DataGridView1.AutoResizeColumns()
End Sub