Skip site navigation (1) Skip section navigation (2)

insert and update in

From: Freeking Wu <whtech(at)gmail(dot)com>
To: pgsql-odbc(at)postgresql(dot)org
Subject: insert and update in
Date: 2005-12-19 12:45:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-odbc
hi, I want to operate the postgres database via I download the
postgres server 8.1  and the latest pgsql-odbc drviers. But question comes.
I can select data from db correctly . But when I insert or update the data,
no error or exception occurs. but the db takes no effect. I test the odbc
driver with access 2002 and I can update or insert data. I changed several
parameters with the connection string .But it doesn't work .How can I do?

following is my main code.

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
        Dim strConn As String
        strConn = "DRIVER=PostgreSQL
        'strConn = "DRIVER={PostgreSQL
        & "Protocol=6.4;" _
        & "ReadOnly=1;" _
        & "SSLMODE=disable;" _
        & "PORT=5432;" _
        & "SERVER=localhost;" _
        & "DATABASE=test;"
        'strConn = "dsn=test;uid=postgres;pwd=postgres"

        Dim cnDb As OdbcConnection
        Dim dsDB As New DataSet
        Dim adDb As OdbcDataAdapter
        Dim cbDb As OdbcCommandBuilder
        Dim cmd As OdbcCommand
        Dim cmdIns As OdbcCommand

            cnDb = New OdbcConnection(strConn)
            dsDB = New DataSet
            adDb = New OdbcDataAdapter
            cbDb = New OdbcCommandBuilder(adDb)

            ' Create the SelectCommand.

            cmd = New OdbcCommand("SELECT * FROM test ", cnDb) ' & _
            '"WHERE id = ? ", cnDb)

            'cmd.Parameters.Add("@id", OdbcType.NVarChar, "1")

            adDb.SelectCommand = cmd

            'adDb.UpdateCommand = New OdbcCommand(strConn, cnDb)
            cmd = New OdbcCommand("UPDATE test SET name = ? " & _
                                 "WHERE id = ?", cnDb)

            cmd.Parameters.Add("@name", OdbcType.NChar, 50, "test444")
            cmd.Parameters.Add("@id", OdbcType.Int, 8, 4)

            adDb.UpdateCommand = cmd

            cmdIns = New OdbcCommand("INSERT INTO test values(100,'100')",
            adDb.InsertCommand = cmdIns


            If Not cnDb Is Nothing Then cnDb.Dispose()
        End Try
    End Sub


pgsql-odbc by date

Next:From: Ludek FinstrleDate: 2005-12-19 12:56:32
Subject: Re: insert and update in
Previous:From: Dave PageDate: 2005-12-19 08:48:54
Subject: Re: psqlODBC 8.01.0105 Development snapshot

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group