Strange Behavior - ADO and SQL Server 6.5 
Author Message
 Strange Behavior - ADO and SQL Server 6.5

Hi,

I have this table in SQL Server 6.5:

CREATE TABLE "dbo"."Lan_Valores" (
 "ID_Item" "int" IDENTITY (1, 1) NOT NULL ,
 "ID_Lan" "int" NOT NULL ,
 "ID_Conta" "int" NOT NULL ,
 "NoDocto" char (50) NULL ,
 "Tipo" char (1) NOT NULL ,
 "Historico" "text" NULL ,
 "Valor" "float" NOT NULL ,
 "INStamp" "timestamp" NULL ,
 CONSTRAINT "PK_Lan_Valores_1__15" PRIMARY KEY  CLUSTERED
 (
  "ID_Item"
 )
)

And in a VB6 code, I insert values using this:

      SQLEx = "insert into lan_valores (ID_Lan, ID_Conta, NoDocto, Tipo,
Historico, Valor) "
      SQLEx = SQLEx & "values"
      SQLEx = SQLEx & " ( "
      SQLEx = SQLEx & IDLan & ", "
      SQLEx = SQLEx & CamposVal(i).cpID_Conta & ", "
      SQLEx = SQLEx & "'" & CamposVal(i).cpNoDocto & "', "
      SQLEx = SQLEx & "'" & CamposVal(i).cpTipo & "', "
      SQLEx = SQLEx & "'" & CamposVal(i).cpHistorico & "', "
      SQLEx = SQLEx & "" & VerValor(CamposVal(i).cpValor) & ""
      SQLEx = SQLEx & ")"

      DataEnvironment1.ConnectionSQL.Execute SQLEx, , ADODB.adCmdText

It has been work very well for weeks, but now, I got:

Violation of PRIMARY KEY constraint 'PK_Lan_Valores_1__15': Attempt to
insert duplicate key in object 'Lan_Valores'.

I receive the same error if in other table with ADO Method ADDNEW

(I dont know who is inserting an existing KEY in the table? ADO or SQL
Server?)

I think its an ADO bug, but I dont know why its worked well for a couple of
weeks.

Someone has experienced this trouble?

Regards,

--
Hammett
http://www.*-*-*.com/



Sun, 22 Apr 2001 03:00:00 GMT  
 Strange Behavior - ADO and SQL Server 6.5
Yeah Folks, Its a SQL Server problem that could be resolved with a couple of
stored procedures posted in public.sqlserver.programming by Steve Robinson.

Thanks guys!

--
Hammett
http://www.puruca.com.br/gcs/



Sun, 22 Apr 2001 03:00:00 GMT  
 Strange Behavior - ADO and SQL Server 6.5
DBCC CHECKINDENT....
Quote:

> Hi,

> I have this table in SQL Server 6.5:

> CREATE TABLE "dbo"."Lan_Valores" (
>  "ID_Item" "int" IDENTITY (1, 1) NOT NULL ,
>  "ID_Lan" "int" NOT NULL ,
>  "ID_Conta" "int" NOT NULL ,
>  "NoDocto" char (50) NULL ,
>  "Tipo" char (1) NOT NULL ,
>  "Historico" "text" NULL ,
>  "Valor" "float" NOT NULL ,
>  "INStamp" "timestamp" NULL ,
>  CONSTRAINT "PK_Lan_Valores_1__15" PRIMARY KEY  CLUSTERED
>  (
>   "ID_Item"
>  )
> )

> And in a VB6 code, I insert values using this:

>       SQLEx = "insert into lan_valores (ID_Lan, ID_Conta, NoDocto, Tipo,
> Historico, Valor) "
>       SQLEx = SQLEx & "values"
>       SQLEx = SQLEx & " ( "
>       SQLEx = SQLEx & IDLan & ", "
>       SQLEx = SQLEx & CamposVal(i).cpID_Conta & ", "
>       SQLEx = SQLEx & "'" & CamposVal(i).cpNoDocto & "', "
>       SQLEx = SQLEx & "'" & CamposVal(i).cpTipo & "', "
>       SQLEx = SQLEx & "'" & CamposVal(i).cpHistorico & "', "
>       SQLEx = SQLEx & "" & VerValor(CamposVal(i).cpValor) & ""
>       SQLEx = SQLEx & ")"

>       DataEnvironment1.ConnectionSQL.Execute SQLEx, , ADODB.adCmdText

> It has been work very well for weeks, but now, I got:

> Violation of PRIMARY KEY constraint 'PK_Lan_Valores_1__15': Attempt to
> insert duplicate key in object 'Lan_Valores'.

> I receive the same error if in other table with ADO Method ADDNEW

> (I dont know who is inserting an existing KEY in the table? ADO or SQL
> Server?)

> I think its an ADO bug, but I dont know why its worked well for a couple of
> weeks.

> Someone has experienced this trouble?

> Regards,

> --
> Hammett
> http://www.puruca.com.br/gcs/



Sun, 22 Apr 2001 03:00:00 GMT  
 Strange Behavior - ADO and SQL Server 6.5

Quote:

>DBCC CHECKINDENT....

Sorry! I think SQL Server 6.5 does not have this SP.
When I tried I gotta the following error:

DBCC CHECKINDENT

Msg 2526, Level 16, State 3
Incorrect DBCC command. Please check the Commands Reference Manual for the
correct DBCC syntax and options.

Regards,

Hammett
http://www.puruca.com.br/gcs/



Sun, 22 Apr 2001 03:00:00 GMT  
 Strange Behavior - ADO and SQL Server 6.5
Hammet,

 dbcc checkident(tablename)

 Francis mis-keyed

 Neil Pike MVP/MCSE
 Protech Computing Ltd
 (Please post ALL replies to the newsgroup only unless indicated otherwise)



Sun, 22 Apr 2001 03:00:00 GMT  
 Strange Behavior - ADO and SQL Server 6.5

Quote:

>Hammet,

> dbcc checkident(tablename)

Thanks! I was almost reinstaling SQL Server! :-)

Regards,

Hammett
http://www.puruca.com.br/gcs/



Mon, 23 Apr 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Strange Behavior - ADO and SQL Server 6.5

2. Data objects closed error in ADO 2.1 and SQL server 6.5

3. sql server 6.5 ado error

4. ADO OLEDB SQL Server 6.5

5. ADO 2.0 connection to SQL Server 6.5

6. SQL Server 6.5 & VB6 ADO

7. ADO 1.5 - VB5.0 - SQL Server 6.5

8. VB5, ADO 1.5, SQL Server 6.5 problem

9. VB5 / ADO 1.5 / SQL Server 6.5

10. SQL Server 6.5 + ADO problem...

11. ADO 2.1/SQL Server 6.5 - IDENTITY Question

12. ADO's Connection.beginTran will lock SQL Server 6.5

 

 
Powered by phpBB® Forum Software