Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

type incompatible

Status
Not open for further replies.

MrBaRRon

Programmer
Aug 8, 2003
39
IT
I really don't understand. I've got an error :

Erreur d'exécution Microsoft VBScript error '800a000d'

Type incompatible


My source field "numaffaire_pro" is bigint
My destination field "test" is bigint

This is my code :

Sub OpenDatabase(ByRef dbConn)
Set dbConn = Server.CreateObject("ADODB.Connection")
dbConn.ConnectionTimeout = 15
dbConn.CommandTimeout = 30
dbConn.Open " DSN=BIZCONNEX;UID=sa;PWD=%!ellAir;DATABASE=BIZMANA
G"

End Sub

The above connection code is in a tools.inc


The following code is in my asp page :

Dim Dern_num_aff_pro, res_Dern_num_aff_pro, Dern_num_aff, res_Dern_num_aff, res_final

OpenDatabase dbconn


Dern_num_aff_pro = "SELECT MAX(numaffaire_pro) FROM [BIZMANAG].[dbo].[FACTURES]"

set res_Dern_num_aff_pro = dbconn.Execute(Dern_num_aff_pro)



Dim ajout_affaire_chantier

ajout_affaire_chantier = "INSERT INTO BIZMANAG.dbo.CHANTIERS(shift, status, type, test) VALUES(' " & shift & " ', '" & Request.Form("status") & "' , '" & Request.Form("type") & "', '" & res_Dern_num_aff_pro & "' ) "

dbconn.Execute(ajout_affaire_chantier)



Please Help me

 
I think your problem is, you are getting the result of the MAX() from the first SQL statement into a recordset object called res_Dern_num_aff_pro.

You are then trying to concatenate the whole object to the second SQL string. What you need to do is get the value out of the recordset.

Change you first SQL statement to include a column alias:

Code:
Dern_num_aff_pro = "SELECT MAX(numaffaire_pro) AS maxnum FROM [BIZMANAG].[dbo].[FACTURES]"

Then set up your second SQL as:

Code:
ajout_affaire_chantier = "INSERT INTO BIZMANAG.dbo.CHANTIERS(shift, status, type, test) VALUES(' " & shift & " ', '" & Request.Form("status") & "' , '" & Request.Form("type") & "', " & res_Dern_num_aff_pro("maxnum") & ")"

Note I have removed the quotes from the last value as it is a number.

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top