Jump to content
Windows Dragon

Base de dados (Alterar um valor)

Recommended Posts

Windows Dragon

Boas pessoal... bem eu tenho este codigo

Dim dbloc As String = INIAPI.INI.Read(Application.StartupPath & "\config.ini", "db", "location", "C:\DataBase1.accdb")
        con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbloc & ";Persist Security Info=False")
        Dim da As New OleDbDataAdapter("SELECT [frn],[lsn],[entered],[lde] FROM gymusers", con)
        Dim dt As New DataTable
        da.Fill(dt)
        dt.Columns(0).ColumnName = "Primeiro Nome"
        dt.Columns(1).ColumnName = "Apelido"
        dt.Columns(2).ColumnName = "Já entrou..."
        dt.Columns(3).ColumnName = "Limite de entradas"
        DataGrid1.DataSource = dt
        da.Dispose()
        con.Close()

E quero que o programa ao carregar os valores para a DataGridView altere os valores iguais a 1000000000000000 para Livre... mas nao que as altere na base de dados...

Alguma ideia?

Share this post


Link to post
Share on other sites
Andrepereira9

boas

Experimenta isto no evento CellFormatting, do DataGrid.

Este exemplo vai percorrer todas as colunas existentes, mas se quiseres so determinda coluna tiras  ciclo for, e onde esta o 'i', metes o numero da coluna

    Private Sub DataGrid1_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGrid1.CellFormatting
For i As Integer = 0 To DataGrid1.ColumnCount
            If e.ColumnIndex = i Then
                If e.Value = "1000000000000000" Then
                    e.Value = "Livre"
                End If
            End If
        Next
    End Sub


A informática chegou para resolver problemas que antes não existiam

Quem ri por último é porque está conectado a 52 Kbs.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.