Update table in PostGreSQL using Visual Basic 2008

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paulache
    New Member
    • May 2011
    • 1

    #1

    Update table in PostGreSQL using Visual Basic 2008

    Hi guys!

    I need some help. I`ve created a database in postgre and linked it to vb. All good till now.
    The problem: I want that when i press the "rezerva" button the field "disponibilitat e" to update to "rezervat", that means it must update itself in the database. Unfortunatelly, I am new in VB.net and I don't know how to do it exactly. I've attached the photo and the code. Thanks in advance!

    Code:
    Imports System.Data.Odbc
    Public Class Form4
        Public conexiune As New OdbcConnection()
        Dim comanda As New OdbcCommand()
    
        Private Sub SplitContainer1_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer1.SplitterMoved
    
        End Sub
    
        Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'PostgresDataSet.dateimprumutrestituire' table. You can move, or remove it, as needed.
            Me.DateimprumutrestituireTableAdapter.Fill(Me.PostgresDataSet.dateimprumutrestituire)
            conexiune.ConnectionString = "Driver={PostgreSQL ANSI};database=postgres;server=localhost;port=5432;uid=postgres;pwd=postgres;sslmode=disable;readonly=0;protocol=7.4;fakeoidindex=0;showoidcolumn=0;rowversioning=0;showsystemtables=0;fetch=100;socket=4096;unknownsizes=0;maxvarcharsize=255;maxlongvarcharsize=8190;debug=0;commlog=0;optimizer=0;ksqo=1;usedeclarefetch=0;textaslongvarchar=1;unknownsaslongvarchar=0;boolsaschar=1;parse=0;cancelasfreestmt=0;extrasystableprefixes=dd_;lfconversion=1;updatablecursors=1;disallowpremature=0;trueisminus1=0;bi=0;byteaaslongvarbinary=0;useserversideprepare=0;lowercaseidentifier=0;xaopt=1"
            conexiune.Open()
    
        End Sub
    
        Private Sub btnCauta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCauta.Click
            Me.DateimprumutrestituireBindingSource.Filter = "autor = '" & Me.txtCuvinteCheie.Text & " ' "
        End Sub
    
        Private Sub btnInchide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInchide.Click
            Me.Close()
        End Sub
    
        Private Sub btnAdauga_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdauga.Click
            MsgBox("Cartea cu cota " + CotaLabel1.Text + " a fost rezervata cu succes!")
            Try
                comanda.CommandText = "UPDATE dateimprumutrestituire SET disponibilitate='rezervat'"
                comanda.Connection = Me.conexiune
                comanda.ExecuteNonQuery()
            Catch eroare As Odbc.OdbcException
                MessageBox.Show("Cartea nu a putut fi rezervata" & Chr(13) & eroare.Message)
    
            End Try
    
        End Sub
    End Class
    [imgnothumb]http://bytes.com/attachments/attachment/5188d1306621527/prt.jpg[/imgnothumb]
    Attached Files
    Last edited by Niheel; Jun 7 '11, 05:30 AM.
Working...