insert and update in vb.net

insert and update in vb.net

am 19.12.2005 13:45:28 von Freeking Wu

------=_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 et">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") r>            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--

Re: insert and update in vb.net

am 19.12.2005 13:56:32 von Ludek Finstrle

> 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.

What version do you mean with "latest pgsql-odbc drviers"?

> 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?

Could you post mylog output? I want check if problem isn't in ODBC driver.

Thanks,

Luf

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Re: insert and update in vb.net

am 19.12.2005 14:30:39 von Freeking Wu

------=_Part_3051_20763416.1134999039933
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

pgsql odbc driver is 8.01.02 . following is the log file. thank you very
much

[2032]globals.extra_systable_prefixes =3D 'dd_;'
[2032][[SQLAllocHandle]][2032]**** in PGAPI_AllocEnv **
[2032]** exit PGAPI_AllocEnv: phenv =3D 94773136 **
[2032][[SQLSetEnvAttr]] att=3D200,3
[2032][[SQLAllocHandle]][2032]PGAPI_AllocConnect: entering...
[2032]**** PGAPI_AllocConnect: henv =3D 94773136, conn =3D 94779272
[2032]EN_add_connection: self =3D 94773136, conn =3D 94779272
[2032] added at i =3D0, conn->henv =3D 94773136, conns[i]->henv =3D 9=
4773136
[2032][SQLGetInfo(30)][2032]PGAPI_GetInfo: entering...fInfoType=3D77
[2032]PGAPI_GetInfo: p=3D'03.00', len=3D5, value=3D0, cbMax=3D12
[2032][[SQLSetConnectAttr]] 103
[2032]PGAPI_SetConnectAttr 103
[2032]PGAPI_SetConnectOption: entering fOption =3D 103 vParam =3D 15
[2032][SQLDriverConnect][2032]PGAPI_DriverConnect: entering...
[2032]**** PGAPI_DriverConnect: fDriverCompletion=3D0,
connStrIn=3D'DSN=3Dtest;UID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]our_connect_string =3D 'DSN=3Dtest;UID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]attribute =3D 'DSN', value =3D 'test'
[2032]copyAttributes:
DSN=3D'test',server=3D'',dbase=3D'',user=3D'',passwd=3D'xxxx x',port=3D'',ss=
lmode=3D'',onlyread=3D'',protocol=3D'',conn_settings=3D'',di sallow_prematur=
e=3D-1)
[2032]attribute =3D 'UID', value =3D 'postgres'
[2032]copyAttributes:
DSN=3D'test',server=3D'',dbase=3D'',user=3D'postgres',passwd =3D'xxxxx',port=
=3D'',sslmode=3D'',onlyread=3D'',protocol=3D'',conn_settings =3D'',disallow_=
premature=3D-1)
[2032]attribute =3D 'PWD', value =3D 'xxxxx'
[2032]copyAttributes:
DSN=3D'test',server=3D'',dbase=3D'',user=3D'postgres',passwd =3D'xxxxx',port=
=3D'',sslmode=3D'',onlyread=3D'',protocol=3D'',conn_settings =3D'',disallow_=
premature=3D-1)
[2032]globals.extra_systable_prefixes =3D 'dd_;'
[2032]globals.extra_systable_prefixes =3D 'dd_;'
[2032]our_connect_string =3D 'DSN=3Dtest;UID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]attribute =3D 'DSN', value =3D 'test'
[2032]CopyCommonAttributes:
A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D8190;B2=3D0;B3=3D0;B 4=3D1;B5=3D1;B6=
=3D0;B7=3D1;B8=3D0;B9=3D1;C0=3D0;C1=3D0;C2=3Ddd_;[2032]attri bute
=3D 'UID', value =3D 'postgres'
[2032]CopyCommonAttributes:
A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D8190;B2=3D0;B3=3D0;B 4=3D1;B5=3D1;B6=
=3D0;B7=3D1;B8=3D0;B9=3D1;C0=3D0;C1=3D0;C2=3Ddd_;[2032]attri bute
=3D 'PWD', value =3D 'xxxxx'
[2032]CopyCommonAttributes:
A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D8190;B2=3D0;B3=3D0;B 4=3D1;B5=3D1;B6=
=3D0;B7=3D1;B8=3D0;B9=3D1;C0=3D0;C1=3D0;C2=3Ddd_;[2032]PGAPI _Disconnect:
about to CC_cleanup
[2032]in CC_Cleanup, self=3D94779272
[2032]after CC_abort
[2032]entering PGCONN_Destructor
[2032]exiting PGCONN_Destructor
[2032]after LIBPQ destructor
[2032]exit CC_Cleanup
[2032]PGAPI_Disconnect: done CC_cleanup
[2032]PGAPI_Disconnect: returning...
[2032][[SQLFreeHandle]][2032]PGAPI_FreeConnect: entering...
[2032]**** in PGAPI_FreeConnect: hdbc=3D94779272
[2032]enter CC_Destructor, self=3D94779272
[2032]in CC_Cleanup, self=3D94779272
[2032]after LIBPQ destructor
[2032]exit CC_Cleanup
[2032]after CC_Cleanup
[2032]after free statement holders
[2032]exit CC_Destructor
[2032]PGAPI_FreeConnect: returning...
[2032][[SQLFreeHandle]][2032]**** in PGAPI_FreeEnv: env =3D 94773136 **
[2032]in EN_Destructor, self=3D94773136
[2032]exit EN_Destructor: rv =3D 1
[2032] ok
[2032][[SQLAllocHandle]][2032]**** in PGAPI_AllocEnv **
[2032]** exit PGAPI_AllocEnv: phenv =3D 94773136 **
[2032][[SQLSetEnvAttr]] att=3D200,3
[2032][[SQLAllocHandle]][2032]PGAPI_AllocConnect: entering...
[2032]**** PGAPI_AllocConnect: henv =3D 94773136, conn =3D 94779272
[2032]EN_add_connection: self =3D 94773136, conn =3D 94779272
[2032] added at i =3D0, conn->henv =3D 94773136, conns[i]->henv =3D 9=
4773136
[2032][SQLGetInfo(30)][2032]PGAPI_GetInfo: entering...fInfoType=3D77
[2032]PGAPI_GetInfo: p=3D'03.00', len=3D5, value=3D0, cbMax=3D12
[2032][[SQLSetConnectAttr]] 103
[2032]PGAPI_SetConnectAttr 103
[2032]PGAPI_SetConnectOption: entering fOption =3D 103 vParam =3D 15
[2032][SQLDriverConnect][2032]PGAPI_DriverConnect: entering...
[2032]**** PGAPI_DriverConnect: fDriverCompletion=3D0,
connStrIn=3D'DSN=3Dtest;UID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]our_connect_string =3D 'DSN=3Dtest;UID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]attribute =3D 'DSN', value =3D 'test'
[2032]copyAttributes:
DSN=3D'test',server=3D'',dbase=3D'',user=3D'',passwd=3D'xxxx x',port=3D'',ss=
lmode=3D'',onlyread=3D'',protocol=3D'',conn_settings=3D'',di sallow_prematur=
e=3D-1)
[2032]attribute =3D 'UID', value =3D 'postgres'
[2032]copyAttributes:
DSN=3D'test',server=3D'',dbase=3D'',user=3D'postgres',passwd =3D'xxxxx',port=
=3D'',sslmode=3D'',onlyread=3D'',protocol=3D'',conn_settings =3D'',disallow_=
premature=3D-1)
[2032]attribute =3D 'PWD', value =3D 'xxxxx'
[2032]copyAttributes:
DSN=3D'test',server=3D'',dbase=3D'',user=3D'postgres',passwd =3D'xxxxx',port=
=3D'',sslmode=3D'',onlyread=3D'',protocol=3D'',conn_settings =3D'',disallow_=
premature=3D-1)
[2032]globals.extra_systable_prefixes =3D 'dd_;'
[2032]globals.extra_systable_prefixes =3D 'dd_;'
[2032]our_connect_string =3D 'DSN=3Dtest;UID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]attribute =3D 'DSN', value =3D 'test'
[2032]CopyCommonAttributes:
A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D8190;B2=3D0;B3=3D0;B 4=3D1;B5=3D1;B6=
=3D0;B7=3D1;B8=3D0;B9=3D1;C0=3D0;C1=3D0;C2=3Ddd_;[2032]attri bute
=3D 'UID', value =3D 'postgres'
[2032]CopyCommonAttributes:
A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D8190;B2=3D0;B3=3D0;B 4=3D1;B5=3D1;B6=
=3D0;B7=3D1;B8=3D0;B9=3D1;C0=3D0;C1=3D0;C2=3Ddd_;[2032]attri bute
=3D 'PWD', value =3D 'xxxxx'
[2032]CopyCommonAttributes:
A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D8190;B2=3D0;B3=3D0;B 4=3D1;B5=3D1;B6=
=3D0;B7=3D1;B8=3D0;B9=3D1;C0=3D0;C1=3D0;C2=3Ddd_;[2032]PGAPI _Disconnect:
about to CC_cleanup
[2032]in CC_Cleanup, self=3D94779272
[2032]after CC_abort
[2032]entering PGCONN_Destructor
[2032]exiting PGCONN_Destructor
[2032]after LIBPQ destructor
[2032]exit CC_Cleanup
[2032]PGAPI_Disconnect: done CC_cleanup
[2032]PGAPI_Disconnect: returning...
[2032][[SQLFreeHandle]][2032]PGAPI_FreeConnect: entering...
[2032]**** in PGAPI_FreeConnect: hdbc=3D94779272
[2032]enter CC_Destructor, self=3D94779272
[2032]in CC_Cleanup, self=3D94779272
[2032]after LIBPQ destructor
[2032]exit CC_Cleanup
[2032]after CC_Cleanup
[2032]after free statement holders
[2032]exit CC_Destructor
[2032]PGAPI_FreeConnect: returning...
[2032][[SQLFreeHandle]][2032]**** in PGAPI_FreeEnv: env =3D 94773136 **
[2032]in EN_Destructor, self=3D94773136
[2032]exit EN_Destructor: rv =3D 1
[2032] ok



On 12/19/05, Ludek Finstrle wrote:
>
> > 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.
>
> What version do you mean with "latest pgsql-odbc drviers"?
>
> > 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?
>
> Could you post mylog output? I want check if problem isn't in ODBC driver=
..
>
> Thanks,
>
> Luf
>

------=_Part_3051_20763416.1134999039933
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

pgsql odbc driver is 8.01.02 . following is the log file. thank you ve=
ry much

 

[2032]globals.extra_systable_prefixes =3D 'dd_;'
[2032][[SQLAllocHa=
ndle]][2032]**** in PGAPI_AllocEnv **
[2032]** exit PGAPI_AllocEnv: phe=
nv =3D 94773136 **
[2032][[SQLSetEnvAttr]] att=3D200,3
[2032][[SQLAll=
ocHandle]][2032]PGAPI_AllocConnect: entering...

[2032]**** PGAPI_AllocConnect: henv =3D 94773136, conn =3D 94779272
=
[2032]EN_add_connection: self =3D 94773136, conn =3D 94779272
[2032]&nbs=
p;      added at i =3D0, conn->henv =3D 9477313=
6, conns[i]->henv =3D 94773136
[2032][SQLGetInfo(30)][2032]PGAPI_GetI=
nfo: entering...fInfoType=3D77

[2032]PGAPI_GetInfo: p=3D'03.00', len=3D5, value=3D0, cbMax=3D12
[20=
32][[SQLSetConnectAttr]] 103
[2032]PGAPI_SetConnectAttr 103
[2032]PGA=
PI_SetConnectOption: entering fOption =3D 103 vParam =3D 15
[2032][SQLDr=
iverConnect][2032]PGAPI_DriverConnect: entering...

[2032]**** PGAPI_DriverConnect: fDriverCompletion=3D0, connStrIn=3D'DSN=
=3Dtest;UID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]our_connect_string =3D 'DS=
N=3Dtest;UID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]attribute =3D 'DSN', valu=
e =3D 'test'
[2032]copyAttributes: DSN=3D'test',server=3D'',dbase=3D'',u=
ser=3D'',passwd=3D'xxxxx',port=3D'',sslmode=3D'',onlyread=3D '',protocol=3D'=
',conn_settings=3D'',disallow_premature=3D-1)

[2032]attribute =3D 'UID', value =3D 'postgres'
[2032]copyAttributes=
: DSN=3D'test',server=3D'',dbase=3D'',user=3D'postgres',passwd =3D'xxxxx',po=
rt=3D'',sslmode=3D'',onlyread=3D'',protocol=3D'',conn_settin gs=3D'',disallo=
w_premature=3D-1)
[2032]attribute =3D 'PWD', value =3D 'xxxxx'

[2032]copyAttributes: DSN=3D'test',server=3D'',dbase=3D'',user=3D'postg=
res',passwd=3D'xxxxx',port=3D'',sslmode=3D'',onlyread=3D'',p rotocol=3D'',co=
nn_settings=3D'',disallow_premature=3D-1)
[2032]globals.extra_systable_p=
refixes =3D 'dd_;'

[2032]globals.extra_systable_prefixes =3D 'dd_;'
[2032]our_connect_strin=
g =3D 'DSN=3Dtest;UID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]attribute =3D 'D=
SN', value =3D 'test'
[2032]CopyCommonAttributes: A7=3D100;A8=3D8192;A9=
=3D0;B0=3D254;B1=3D8190;B2=3D0;B3=3D0;B4=3D1;B5=3D1;B6=3D0;B 7=3D1;B8=3D0;B9=
=3D1;C0=3D0;C1=3D0;C2=3Ddd_;[2032]attribute =3D 'UID', value =3D 'postgres'

[2032]CopyCommonAttributes: A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D819=
0;B2=3D0;B3=3D0;B4=3D1;B5=3D1;B6=3D0;B7=3D1;B8=3D0;B9=3D1;C0 =3D0;C1=3D0;C2=
=3Ddd_;[2032]attribute =3D 'PWD', value =3D 'xxxxx'
[2032]CopyCommonAttr=
ibutes: A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D8190;B2=3D0;B3=3D0;B 4=3D1;B=
5=3D1;B6=3D0;B7=3D1;B8=3D0;B9=3D1;C0=3D0;C1=3D0;C2=3Ddd_;[20 32]PGAPI_Discon=
nect: about to CC_cleanup

[2032]in CC_Cleanup, self=3D94779272
[2032]after CC_abort
[2032]e=
ntering PGCONN_Destructor
[2032]exiting PGCONN_Destructor
[2032]aft=
er LIBPQ destructor
[2032]exit CC_Cleanup
[2032]PGAPI_Disconnect: don=
e CC_cleanup

[2032]PGAPI_Disconnect: returning...
[2032][[SQLFreeHandle]][2032]PG=
API_FreeConnect: entering...
[2032]**** in PGAPI_FreeConnect: hdbc=3D947=
79272
[2032]enter CC_Destructor, self=3D94779272
[2032]in CC_Cleanup,=
self=3D94779272

[2032]after LIBPQ destructor
[2032]exit CC_Cleanup
[2032]after CC=
_Cleanup
[2032]after free statement holders
[2032]exit CC_Destructor<=
br>[2032]PGAPI_FreeConnect: returning...
[2032][[SQLFreeHandle]][2032]**=
** in PGAPI_FreeEnv: env =3D 94773136 **=20

[2032]in EN_Destructor, self=3D94773136
[2032]exit EN_Destructor: rv=
=3D 1
[2032]   ok
[2032][[SQLAllocHandle]][2032]**** in PG=
API_AllocEnv **
[2032]** exit PGAPI_AllocEnv: phenv =3D 94773136 **
=
[2032][[SQLSetEnvAttr]] att=3D200,3

[2032][[SQLAllocHandle]][2032]PGAPI_AllocConnect: entering...
[2032]=
**** PGAPI_AllocConnect: henv =3D 94773136, conn =3D 94779272
[2032]EN_a=
dd_connection: self =3D 94773136, conn =3D 94779272
[2032]  &n=
bsp;    added at i =3D0, conn->henv =3D 94773136, conns[i=
]->henv =3D 94773136

[2032][SQLGetInfo(30)][2032]PGAPI_GetInfo: entering...fInfoType=3D77 >[2032]PGAPI_GetInfo: p=3D'03.00', len=3D5, value=3D0, cbMax=3D12
[2032]=
[[SQLSetConnectAttr]] 103
[2032]PGAPI_SetConnectAttr 103
[2032]PGAPI_=
SetConnectOption: entering fOption =3D 103 vParam =3D 15

[2032][SQLDriverConnect][2032]PGAPI_DriverConnect: entering...
[2032=
]**** PGAPI_DriverConnect: fDriverCompletion=3D0, connStrIn=3D'DSN=3Dtest;U=
ID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]our_connect_string =3D 'DSN=3Dtest;=
UID=3Dpostgres;PWD=3Dxxxxxxxx;'

[2032]attribute =3D 'DSN', value =3D 'test'
[2032]copyAttributes: DS=
N=3D'test',server=3D'',dbase=3D'',user=3D'',passwd=3D'xxxxx' ,port=3D'',sslm=
ode=3D'',onlyread=3D'',protocol=3D'',conn_settings=3D'',disa llow_premature=
=3D-1)
[2032]attribute =3D 'UID', value =3D 'postgres'

[2032]copyAttributes: DSN=3D'test',server=3D'',dbase=3D'',user=3D'postg=
res',passwd=3D'xxxxx',port=3D'',sslmode=3D'',onlyread=3D'',p rotocol=3D'',co=
nn_settings=3D'',disallow_premature=3D-1)
[2032]attribute =3D 'PWD', val=
ue =3D 'xxxxx'
[2032]copyAttributes: DSN=3D'test',server=3D'',dbase=3D''=
,user=3D'postgres',passwd=3D'xxxxx',port=3D'',sslmode=3D'',o nlyread=3D'',pr=
otocol=3D'',conn_settings=3D'',disallow_premature=3D-1)

[2032]globals.extra_systable_prefixes =3D 'dd_;'
[2032]globals.extra=
_systable_prefixes =3D 'dd_;'
[2032]our_connect_string =3D 'DSN=3Dtest;U=
ID=3Dpostgres;PWD=3Dxxxxxxxx;'
[2032]attribute =3D 'DSN', value =3D 'tes=
t'
[2032]CopyCommonAttributes: A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D8=
190;B2=3D0;B3=3D0;B4=3D1;B5=3D1;B6=3D0;B7=3D1;B8=3D0;B9=3D1; C0=3D0;C1=3D0;C=
2=3Ddd_;[2032]attribute =3D 'UID', value =3D 'postgres'

[2032]CopyCommonAttributes: A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D819=
0;B2=3D0;B3=3D0;B4=3D1;B5=3D1;B6=3D0;B7=3D1;B8=3D0;B9=3D1;C0 =3D0;C1=3D0;C2=
=3Ddd_;[2032]attribute =3D 'PWD', value =3D 'xxxxx'
[2032]CopyCommonAttr=
ibutes: A7=3D100;A8=3D8192;A9=3D0;B0=3D254;B1=3D8190;B2=3D0;B3=3D0;B 4=3D1;B=
5=3D1;B6=3D0;B7=3D1;B8=3D0;B9=3D1;C0=3D0;C1=3D0;C2=3Ddd_;[20 32]PGAPI_Discon=
nect: about to CC_cleanup

[2032]in CC_Cleanup, self=3D94779272
[2032]after CC_abort
[2032]e=
ntering PGCONN_Destructor
[2032]exiting PGCONN_Destructor
[2032]aft=
er LIBPQ destructor
[2032]exit CC_Cleanup
[2032]PGAPI_Disconnect: don=
e CC_cleanup

[2032]PGAPI_Disconnect: returning...
[2032][[SQLFreeHandle]][2032]PG=
API_FreeConnect: entering...
[2032]**** in PGAPI_FreeConnect: hdbc=3D947=
79272
[2032]enter CC_Destructor, self=3D94779272
[2032]in CC_Cleanup,=
self=3D94779272

[2032]after LIBPQ destructor
[2032]exit CC_Cleanup
[2032]after CC=
_Cleanup
[2032]after free statement holders
[2032]exit CC_Destructor<=
br>[2032]PGAPI_FreeConnect: returning...
[2032][[SQLFreeHandle]][2032]**=
** in PGAPI_FreeEnv: env =3D 94773136 **=20

[2032]in EN_Destructor, self=3D94773136
[2032]exit EN_Destructor: rv=
=3D 1
[2032]   ok


 

On 12/19/05, >Ludek Finstrle <luf@pzkagis.cz >> wrote:
px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">> hi, I want to operate the p=
ostgres database via . I download the r>
> postgres server 8.1  and the latest pgsql-odbc drviers. But =
question comes.

What version do you mean with "latest pgsql-odb=
c drviers"?

> 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 t=
he 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?


Could you post mylog output? I want check if problem isn't in ODBC =
driver.

Thanks,

Luf



------=_Part_3051_20763416.1134999039933--

Re: insert and update in vb.net

am 19.12.2005 14:50:20 von Ludek Finstrle

> pgsql odbc driver is 8.01.02 . following is the log file. thank you very
> much

There is only info about connect and disconnect in mylog file.
Either you don't turn on mylog output in DataSource (you tern on it only
in Global) or you attach bad mylog. mylog output is created for setup
dialog too.

Please set mylog output (under Global and DataSource button)
erase C:\mylog_* and then run your application.
Please send me mylog which appear in C:\ after you close you application.

Regards,

Luf

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Re: insert and update in vb.net

am 19.12.2005 16:28:35 von Greg Campbell

This is a multi-part message in MIME format.
--------------020906030304010104030005
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

1. Why not use Npgsql? Are you developing one source to connect to a variety of DB backends?
2. Do you actually need commands with parameters?
3. The order of your construction seems strange. I would expect
a. Create the dataset
b. Update rows in the dataSET
c. Use the dataAdapter w/CommandBuilder to update back to the source
This way the changes to the rows, trigger the rowUpdating event when Command Builder is attached.
4. If I were not going to use the dataset,..like in your example
I would use the much simpler command.ExecuteNonQuery.
This would avoid transferring from server to client all the records (SELECT * FROM test) into a
detatched dataset.

Now if you are going to databind to a control like a grid, the issue is just the order the code units get
called in. In that case you are likely to to construct and bind a dataset in a form_load() and update from
the datset in a grid_afterupdate() event.



Freeking Wu wrote:
> 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 = "DRIVER=PostgreSQL
> ANSI;SERVER=localhost;PORT=5432;UID=postgres;Password=postgr es;DATABASE=test;pwd=postgres;ReadOnly=0"
> 'strConn = "DRIVER={PostgreSQL
> ANSI};UID=postgres;pwd=postgres;LowerCaseIdentifier=0;UseSer verSidePrepare=0;ByteaAsLongVarBinary=0;"
> _
> & "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
>
> Try
> cnDb = New OdbcConnection(strConn)
> cnDb.Open()
> 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')",
> cnDb)
> adDb.InsertCommand = cmdIns
>
> adDb.Fill(dsDB)
> adDb.Update(dsDB)
> cnDb.Close()
>
> Finally
> If Not cnDb Is Nothing Then cnDb.Dispose()
> End Try
> End Sub
>

--------------020906030304010104030005
Content-Type: text/x-vcard; charset=utf-8;
name="greg.campbell.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="greg.campbell.vcf"

begin:vcard
fn:Greg Campbell
n:Campbell;Greg
org:Michelin North America - US5 Lexington;ENG-ASE
email;internet:greg.campbell@us.michelin.com
title:ASE Systems Engineer
tel;work:803-951-5561/x75561
x-mozilla-html:FALSE
version:2.1
end:vcard


--------------020906030304010104030005
Content-Type: text/plain
Content-Disposition: inline
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

--------------020906030304010104030005--