How to programmatically set a data cell of database in VB.Net?

Posted by manuel on Stack Overflow See other posts from Stack Overflow or by manuel
Published on 2010-04-17T15:08:12Z Indexed on 2010/04/17 17:03 UTC
Read the original article Hit count: 259

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about ms-access