hi guys, i'm having a problem manipulating the datagridview.
i have an access database named "ETB.mdb" and a table inside it named "ETB"
it is a read-only database and it has to stay that way, anyway, what i'm trying to do is to retrieve the data on the database put it in the datagridview, add a column at the end of the datagridview, i have accomplished that using this:

DataGridView1.Columns.Add("SG", "SG")

(SG is the name of the added column)
after adding the column, i wanted to populate it with data using this query:

UPDATE ETB SET ETB.SG = 'SME' WHERE (((ETB.Sales_Group) Like 'SME*'))

and i don't know how would i do that, and i'm confused as to what SET would it be, because i know that the SG column i've added has not been saved on the database. so is there a way to populate the column i've added on the datagridview using a query(with those condition) i'm confused on how to add the "SME" tag on SG column(that is only on the datagridview, not on the dbase) wherein the "Sales_Group" column on the database contains an "SME" word on it.

by the way, here's my code on how i called the whole ETB dbase:

Dim con As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ETB.mdb"
    Dim conn As OleDbConnection = New OleDbConnection(con)
    Dim comm As OleDbCommand

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim dataadapter As OleDbDataAdapter
        Dim ds As DataSet = New DataSet()
        Dim startDate As Date
        Dim endDate As Date
        startDate = DateTimePicker1.Value
        endDate = DateTimePicker2.Value
        Dim sql As String = "SELECT * FROM(ETB) WHERE (((ETB.[SENT])>=# " & startDate.Date & " # And (ETB.[SENT])<= # " & endDate.Date & "#))"

        comm = New OleDbCommand(sql, conn)

        dataadapter = New OleDbDataAdapter(comm)


        dataadapter.Fill(ds, "ETB")


        DataGridView1.DataSource = ds

        DataGridView1.DataMember = "ETB"

    End Sub


7 Years
Discussion Span
Last Post by lolafuertes

You can change the select to reflect the new column like

Dim sql As String = "SELECT *, Left(ETB.[SalesGroup],3) AS SG FROM(ETB) WHERE (((ETB.[SENT])>=# " & startDate.Date & " # And (ETB.[SENT])<= # " & endDate.Date & "#))"

Hope this helps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.