Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id CB2322E3D58 for ; Fri, 14 Dec 2007 13:33:08 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 80183-02-2 for ; Fri, 14 Dec 2007 13:33:02 -0400 (AST) Received: from mout.perfora.net (mout.perfora.net [74.208.4.197]) by postgresql.org (Postfix) with ESMTP id BFB6C2E3D61 for ; Fri, 14 Dec 2007 13:33:02 -0400 (AST) Received: from pustefix134.perfora.net (pustefix134.perfora.net [172.19.56.138]) by mrelay.perfora.net (node=mrus0) with ESMTP (Nemesis) id 0MKp8S-1J3EPF1xnB-000736; Fri, 14 Dec 2007 12:33:01 -0500 Message-Id: <18411256.511331197653581482.JavaMail.servlet@perfora> From: lshafranovich@baisyaakov.net To: Subject: weird vb6 odbc null problem MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_30181_11445657.1197653581434" X-Priority: 3 X-Binford: 6100 (more power) X-Mailer: Webmail X-Originating-From: 30759580 X-Routing: US X-Message-Id: <30759580$1197653581434172.19.56.1381104906@pustefix134.perfora.net--1356909354> X-Received: from pustefix134.perfora.net by 66.251.111.178 with HTTP id 30759580 for [pgsql-odbc@postgresql.org]; Fri, 14 Dec 2007 18:33:01 CET Date: Fri, 14 Dec 2007 12:33:01 -0500 X-Provags-ID: V01U2FsdGVkX19VwoWcxOLkeY4/Aloa2nS+A0b0TEU8Jgf1Dsq Wfnt+rwTgldLMMx8r7xBPc9SCM+Z8ar+ZzP5/Zrg7ENwAHeQxe YiS6UvkKbs= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/23 X-Sequence-Number: 9301 ------=_Part_30181_11445657.1197653581434 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi,=C2=A0I'm=C2=A0a=C2=A0newbie=C2=A0to=C2=A0Postgres=C2=A0and=C2=A0ADO/ODB= C=C2=A0programming.=C2=A0=C2=A0I=C2=A0have=C2=A0a=C2=A0weird=C2=A0problem.= =C2=A0=C2=A0I=C2=A0have=C2=A0a=C2=A0table=C2=A0called=C2=A0scoredata=C2=A0w= hich=C2=A0every=C2=A0time=C2=A0I=C2=A0update=C2=A0(from=C2=A0VB6=C2=A0via= =C2=A0ODBC=C2=A0driver=C2=A008.02.0200=C2=A0Postgres=C2=A0version=C2=A08.2.= 5)=C2=A0a=C2=A0specific=C2=A0smallint=C2=A0field=C2=A0to=C2=A0null,=C2=A0it= =C2=A0gets=C2=A0filled=C2=A0in=C2=A0with=C2=A0a=C2=A02,=C2=A04,=C2=A0or=C2= =A06. Here=C2=A0is=C2=A0the=C2=A0applicable=C2=A0code=C2=A0(I=C2=A0simplified=C2= =A0it=C2=A0a=C2=A0little=C2=A0to=C2=A0make=C2=A0it=C2=A0shorter): dim=C2=A0bysCN=C2=A0As=C2=A0New=C2=A0ADODB.Connection dim=C2=A0scoredataRecordset=C2=A0as=C2=A0ADODB.Recordset =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bysCN.ConnectionString=C2=A0=3D=C2=A0"DRIVER= =3D{PostgreSQL=C2=A0 unicode};Server=3Dservername;Port=3D5432;Database=3Dmslocal;Uid=3Ddbadmin;P= wd=3Dpassword;" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bysCN.Mode=C2=A0=3D=C2=A0adModeReadWrite =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bysCN.Open =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Set=C2=A0scoredataRecordset=C2=A0=3D=C2=A0New= =C2=A0ADODB.Recordset =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0scoredataRecordset.CursorLocation=C2=A0=3D=C2= =A0adUseClient =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0scoredataRecordset.Open=C2=A0"select=C2=A0*= =C2=A0from=C2=A0scoredata=C2=A0where=C2=A0"+Chr(34)+"class=C2=A0id"+Chr(34)= +"=C2=A0=3D=C2=A06271",=C2=A0bysCN,=C2=A0 adOpenKeyset,=C2=A0adLockOptimistic =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0... =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0scoredataRecordset.Fields("average")=3DNull =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0scoredataRecordset.Update At=C2=A0this=C2=A0point=C2=A0if=C2=A0I=C2=A0query=C2=A0the=C2=A0database=C2= =A0it=C2=A0the=C2=A0"average"=C2=A0field=C2=A0is=C2=A0filled=C2=A0in=C2=A0w= ith=C2=A0a=C2=A02,4,=C2=A0or=C2=A06.=C2=A0=C2=A0This=C2=A0problem=C2=A0only= =C2=A0seems=C2=A0to=C2=A0happen=C2=A0if=C2=A0the=C2=A0field=C2=A0was=C2=A0n= ot=C2=A0null=C2=A0before=C2=A0but=C2=A0then=C2=A0was=C2=A0changed=C2=A0to= =C2=A0null. This=C2=A0is=C2=A0my=C2=A0table: =C2=A0class=C2=A0id=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0|=C2=A0bigint=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0|=C2=A0not=C2=A0null =C2=A0stud=C2=A0id=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0|=C2=A0integer=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= |=C2=A0not=C2=A0null =C2=A0average=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0|=C2=A0smallint=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| =C2=A0othergrade=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0char= acter=C2=A0varying(5)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| =C2=A0override=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|= =C2=A0character=C2=A0varying(5)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0| =C2=A0deportment=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0char= acter=C2=A0varying(5)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| =C2=A0numericcomments=C2=A0=C2=A0=C2=A0|=C2=A0character=C2=A0varying(25)=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| =C2=A0datecreated=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0timestamp= =C2=A0without=C2=A0time=C2=A0zone=C2=A0|=C2=A0default=C2=A0now() =C2=A0usercreated=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0character= =C2=A0varying(5)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| =C2=A0userupdated=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0character= =C2=A0varying(5)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| =C2=A0othergrade_reason=C2=A0|=C2=A0character=C2=A0varying(2048)=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0| =C2=A0deportment_reason=C2=A0|=C2=A0character=C2=A0varying(2048)=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0| =C2=A0id=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0integer=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0|=C2=A0not=C2=A0null=C2=A0default=C2=A0nextval('scored= ata_id_seq'::regclass) =C2=A0thelevel=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|= =C2=A0smallint=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0default= =C2=A00 =C2=A0comment=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0|=C2=A0character=C2=A0varying(2048)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| Indexes: =C2=A0=C2=A0=C2=A0=C2=A0"scoredata_pkey"=C2=A0PRIMARY=C2=A0KEY,=C2=A0btree= =C2=A0(id) =C2=A0=C2=A0=C2=A0=C2=A0"scoredata_stud_id_class_id"=C2=A0UNIQUE,=C2=A0btre= e=C2=A0("class=C2=A0id",=C2=A0"stud=C2=A0id") =C2=A0=C2=A0=C2=A0=C2=A0"scoredata_class_id"=C2=A0btree=C2=A0("class=C2=A0i= d") =C2=A0=C2=A0=C2=A0=C2=A0"scoredata_stud_id"=C2=A0btree=C2=A0("stud=C2=A0id"= ) Foreign-key=C2=A0constraints: =C2=A0=C2=A0=C2=A0=C2=A0"scoredata_class=C2=A0id_fkey"=C2=A0FOREIGN=C2=A0KE= Y=C2=A0("class=C2=A0id")=C2=A0REFERENCES=C2=A0classes("class=C2=A0id") =C2=A0=C2=A0=C2=A0=C2=A0"scoredata_deportment_fkey"=C2=A0FOREIGN=C2=A0KEY= =C2=A0(deportment)=C2=A0REFERENCES=C2=A0deportment(deportment) =C2=A0=C2=A0=C2=A0=C2=A0"scoredata_othergrade_fkey"=C2=A0FOREIGN=C2=A0KEY= =C2=A0(othergrade)=C2=A0REFERENCES=C2=A0other_grades(other_grades) Thank=C2=A0you=C2=A0so=C2=A0much=C2=A0for=C2=A0your=C2=A0help.=C2=A0=C2=A0I= =C2=A0apologize=C2=A0if=C2=A0I=C2=A0posted=C2=A0or=C2=A0formatted=C2=A0this= =C2=A0incorrectly. L.=C2=A0Shafranovich ------=_Part_30181_11445657.1197653581434 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, I'm a newbie to Postg= res and ADO/ODBC programming.  I have a&= nbsp;weird problem.  I have a table call= ed scoredata which every time I update (= from VB6 via ODBC driver 08.02.0200 Postgres&= nbsp;version 8.2.5) a specific smallint field = ;to null, it gets filled in with a = 2, 4, or 6.
Here is the applicable co= de (I simplified it a little to make&nbs= p;it shorter):

dim bysCN=  As New ADODB.Connection
dim scoredataRecordset = ;as ADODB.Recordset

     bysCN.Connect= ionString =3D "DRIVER=3D{PostgreSQL 
unicode};Server=3Dse= rvername;Port=3D5432;Database=3Dmslocal;Uid=3Ddbadmin;Pwd=3Dpassword;"
&= nbsp;    bysCN.Mode =3D adModeReadWrite
&n= bsp;    bysCN.Open


    &= nbsp;Set scoredataRecordset =3D New ADODB.Recordset
=      scoredataRecordset.CursorLocation =3D&nb= sp;adUseClient
     scoredataRecordset.Open&nbs= p;"select * from scoredata where "+Chr(34)+"class&= nbsp;id"+Chr(34)+" =3D 6271", bysCN, 
adOpenKeyset,&= nbsp;adLockOptimistic
     ...
  &= nbsp;  scoredataRecordset.Fields("average")=3DNull
  = ;   scoredataRecordset.Update

At this = ;point if I query the database it the&nb= sp;"average" field is filled in with a 2= ,4, or 6.  This problem only seems = to happen if the field was not null = ;before but then was changed to null.

= This is my table:
 = ;class id          |=  bigint          &nb= sp;           | = ;not null
 stud id      &nb= sp;    | integer     &nbs= p;            &= nbsp;  | not null
 average   &nb= sp;       | smallint  &nb= sp;            =      |
 othergrade    =     | character varying(5)   &= nbsp;    |
 override    &nb= sp;     | character varying(5) &nbs= p;      |
 deportment  &nbs= p;     | character varying(5)  = ;      |
 numericcomments  =  | character varying(25)      =  |
 datecreated       |&nbs= p;timestamp without time zone | default now()=
 usercreated       | chara= cter varying(5)        |
&n= bsp;userupdated       | character&n= bsp;varying(5)        |
 ot= hergrade_reason | character varying(2048)   &= nbsp; |
 deportment_reason | character varying(= 2048)     |
 id    &nb= sp;           | = ;integer           &= nbsp;         | not = null default nextval('scoredata_id_seq'::regclass)
 thele= vel          | small= int            =         | default 0
&n= bsp;comment          &nbs= p;| character varying(2048)     |
Ind= exes:
    "scoredata_pkey" PRIMARY KEY,&nb= sp;btree (id)
    "scoredata_stud_id_class_id"&= nbsp;UNIQUE, btree ("class id", "stud id")
&nbs= p;   "scoredata_class_id" btree ("class id")<= br>    "scoredata_stud_id" btree ("stud = id")
Foreign-key constraints:
    "scoredata= _class id_fkey" FOREIGN KEY ("class id") REFE= RENCES classes("class id")
    "scoredata_= deportment_fkey" FOREIGN KEY (deportment) REFERENCES&nb= sp;deportment(deportment)
    "scoredata_othergrade_= fkey" FOREIGN KEY (othergrade) REFERENCES other_gr= ades(other_grades)

Thank you so much for&n= bsp;your help.  I apologize if I posted&= nbsp;or formatted this incorrectly.

L. Shafranov= ich

------=_Part_30181_11445657.1197653581434--