X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id AE3EB9DC810 for ; Mon, 19 Dec 2005 08:45:28 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31125-02 for ; Mon, 19 Dec 2005 08:45:30 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.192]) by postgresql.org (Postfix) with ESMTP id 2EA869DC80C for ; Mon, 19 Dec 2005 08:45:24 -0400 (AST) Received: by zproxy.gmail.com with SMTP id 13so1296708nzn for ; Mon, 19 Dec 2005 04:45:28 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=CW8tQrP/DvDxhcWvtfedEe/sY1v186qN1eR3v1AKmc+T1r4Z1lrsP24b7nwQs++pzoLUznVXXdiaTT9bJE28g7Fe463KaOARSdgA8mnUyt+jxrUVYdoPyqrk9O+tGbyXlDv1DbmycpwhG+7HHas0zzvlcMRaPLsYG2IqWQPFBxg= Received: by 10.36.79.5 with SMTP id c5mr3954329nzb; Mon, 19 Dec 2005 04:45:28 -0800 (PST) Received: by 10.36.61.5 with HTTP; Mon, 19 Dec 2005 04:45:28 -0800 (PST) Message-ID: Date: Mon, 19 Dec 2005 20:45:28 +0800 From: Freeking Wu To: pgsql-odbc@postgresql.org Subject: insert and update in vb.net MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2839_24057979.1134996328237" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200512/242 X-Sequence-Number: 6721 ------=_Part_2839_24057979.1134996328237 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline hi, I want to operate the postgres database via vb.net. 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 =3D "DRIVER=3DPostgreSQL ANSI;SERVER=3Dlocalhost;PORT=3D5432;UID=3Dpostgres;Password=3Dpostgres;DATA= BASE=3Dtest;pwd=3Dpostgres;ReadOnly=3D0" 'strConn =3D "DRIVER=3D{PostgreSQL ANSI};UID=3Dpostgres;pwd=3Dpostgres;LowerCaseIdentifier=3D0;UseServerSidePr= epare=3D0;ByteaAsLongVarBinary=3D0;" _ & "Protocol=3D6.4;" _ & "ReadOnly=3D1;" _ & "SSLMODE=3Ddisable;" _ & "PORT=3D5432;" _ & "SERVER=3Dlocalhost;" _ & "DATABASE=3Dtest;" 'strConn =3D "dsn=3Dtest;uid=3Dpostgres;pwd=3Dpostgres" 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 Try cnDb =3D New OdbcConnection(strConn) cnDb.Open() dsDB =3D New DataSet adDb =3D New OdbcDataAdapter cbDb =3D New OdbcCommandBuilder(adDb) ' Create the SelectCommand. cmd =3D New OdbcCommand("SELECT * FROM test ", cnDb) ' & _ '"WHERE id =3D ? ", cnDb) 'cmd.Parameters.Add("@id", OdbcType.NVarChar, "1") adDb.SelectCommand =3D cmd 'adDb.UpdateCommand =3D New OdbcCommand(strConn, cnDb) cmd =3D New OdbcCommand("UPDATE test SET name =3D ? " & _ "WHERE id =3D ?", cnDb) cmd.Parameters.Add("@name", OdbcType.NChar, 50, "test444") cmd.Parameters.Add("@id", OdbcType.Int, 8, 4) adDb.UpdateCommand =3D cmd cmdIns =3D New OdbcCommand("INSERT INTO test values(100,'100')"= , cnDb) adDb.InsertCommand =3D cmdIns adDb.Fill(dsDB) adDb.Update(dsDB) cnDb.Close() Finally If Not cnDb Is Nothing Then cnDb.Dispose() End Try End Sub ------=_Part_2839_24057979.1134996328237 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
hi, I want to operate the postgres database via vb.net. I download the postgres server 8.1  and the latest pgs= ql-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. bu= t 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 st= ring .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 A= s System.EventArgs) Handles Button1.Click
     =    Dim strConn As String
      &= nbsp; strConn =3D "DRIVER=3DPostgreSQL ANSI;SERVER=3Dlocalhost;PORT=3D= 5432;UID=3Dpostgres;Password=3Dpostgres;DATABASE=3Dtest;pwd=3Dpostgres;Read= Only=3D0"
        'strConn =3D "DRIVER=3D= {PostgreSQL ANSI};UID=3Dpostgres;pwd=3Dpostgres;LowerCaseIdentifier=3D0;Use= ServerSidePrepare=3D0;ByteaAsLongVarBinary=3D0;" _
  &nbs= p;     & "Protocol=3D6.4;" _
 &nb= sp;      & "ReadOnly=3D1;" _
        & "SSLMODE=3Ddisabl= e;" _
        & "PORT= =3D5432;" _
        & "= SERVER=3Dlocalhost;" _
        &= amp; "DATABASE=3Dtest;"
      &n= bsp; 'strConn =3D "dsn=3Dtest;uid=3Dpostgres;pwd=3Dpostgres"

        Dim cnDb As OdbcConnection        Dim dsDB As New DataSet
&nbs= p;       Dim adDb As OdbcDataAdapter
 = ;       Dim cbDb As OdbcCommandBuilder
&nb= sp;       Dim cmd As OdbcCommand
 &nb= sp;      Dim cmdIns As OdbcCommand

        Try
   &nbs= p;        cnDb =3D New OdbcConnection(st= rConn)
           = ; cnDb.Open()
         &nbs= p;  dsDB =3D New DataSet
       =      adDb =3D New OdbcDataAdapter
   =          cbDb =3D New OdbcCommandBu= ilder(adDb)

            ' Cre= ate the SelectCommand.

            cmd = =3D New OdbcCommand("SELECT * FROM test ", cnDb) ' & _
&nb= sp;           '"WHER= E id =3D ? ", cnDb)

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

            adDb.= SelectCommand =3D cmd

            'adDb= .UpdateCommand =3D New OdbcCommand(strConn, cnDb)
   &nbs= p;        cmd =3D New OdbcCommand("= UPDATE test SET name =3D ? " & _
     =             &nb= sp;            =    "WHERE id =3D ?", cnDb)

            cmd.P= arameters.Add("@name", OdbcType.NChar, 50, "test444")            cmd.Pa= rameters.Add("@id", OdbcType.Int, 8, 4)

            adDb.= UpdateCommand =3D cmd

            cmdIn= s =3D New OdbcCommand("INSERT INTO test values(100,'100')", cnDb)=
            adDb= .InsertCommand =3D cmdIns

            adDb.= Fill(dsDB)
          &= nbsp; adDb.Update(dsDB)
        =     cnDb.Close()

        Finally
   =          If Not cnDb Is Nothing The= n cnDb.Dispose()
        End Try
&= nbsp;   End Sub

------=_Part_2839_24057979.1134996328237--